首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Linux之生产者消费者模型(上)——单生产者单消费者

    引入: 举个例子,我们想买个生活用品,但是没有交易场所的话,我们就只能直接去供货商那里去买。我们每人每次买一两件,对于供货商来说,为了这一两件商品去开启厂子里的机器进行生产,是很亏本的事情。因此,有了交易场所——超市等存在,它们作为交易商品的媒介,工作就是集中需求,分发产品。 消费者和生产者之间通过超市进行交易。当消费者没有消费的同时,生产者也可以继续生产;当消费者过来消费的同时,生产者也可以停止生产(例子:周内生产者上班生产商品,学生上学不来超市购买商品;周末生产者放假休息,不进行生产工作,学生过来超市购买商品)。由此,生产和消费这两件事就可以解耦了,我们把临时保存产品的场所称为缓冲区。

    04

    Supermarket超市(贪心算法 优先队列)- POJ 1456

    A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starting from the moment the sale begins. Each product takes precisely one unit of time for being sold. A selling schedule is an ordered subset of products Sell ≤ Prod such that the selling of each product x∈Sell, according to the ordering of Sell, completes before the deadline dx or just when dx expires. The profit of the selling schedule is Profit(Sell)=Σx∈Sellpx. An optimal selling schedule is a schedule with a maximum profit. For example, consider the products Prod={a,b,c,d} with (pa,da)=(50,2), (pb,db)=(10,1), (pc,dc)=(20,2), and (pd,dd)=(30,1). The possible selling schedules are listed in table 1. For instance, the schedule Sell={d,a} shows that the selling of product d starts at time 0 and ends at time 1, while the selling of product a starts at time 1 and ends at time 2. Each of these products is sold by its deadline. Sell is the optimal schedule and its profit is 80.

    02

    干货!大话EXT4文件系统完整版

    我们知道SSD是一场存储革命,设计和制造一个好的SSD固然重要,但如何正确使用以充分发挥SSD性能同样重要。SSD内在的并行性和先擦再写的特性决定了它不同于机械硬盘简单的LBA和存储块一一对应,要充分挖掘SSD的并行性,提升性能,延长寿命,缩短延迟,就必须在上层应用做出改动。很多SSD的使用大户都作出了这种尝试,从国外的Google,Microsoft,Facebook,到国内的Baidu,Alibaba等,本站就曾经介绍过百度的软件定义闪存,把对象存储和SSD内部结构统一起来使用。但对大部分企业来讲,这种结构还是太独特了,我们还是要关注通用的架构,首先来了解离硬盘最近的软件:文件系统。本系列文章将以Linux系统最常见的EXT4文件系统为例,从SSD爱好者的角度来揭开文件系统的庐山真面目。

    03
    领券