操作系统_生产着消费者问题实现
所属分类:进程与线程
开发工具:C/C++
文件大小:1281KB
下载次数:4
上传日期:2019-03-04 13:58:27
上 传 者:
GJLDR
说明: 通过编写多进程程序实现典型的生产者和消费者问题。
?一个大小为3的缓冲区,初始为空
?2个生产者
–随机等待一段时间,往缓冲区添加数据,
–若缓冲区已满,等待消费者取走数据后再添加
–重复6次
?3个消费者
–随机等待一段时间,从缓冲区读取数据
–若缓冲区为空,等待生产者添加数据后再读取
–重复4次
?显示每次添加和读取数据的时间及缓冲区的状态
(Typical producer and consumer problems can be achieved by writing multi-process programs.
A buffer size of 3, initially empty
2 producers
- Wait for a random period of time to add data to the buffer.
- If the buffer is full, wait for the consumer to remove the data before adding it
- Repeat 6 times
3 consumers
- Wait for a random period of time to read data from the buffer
- If the buffer is empty, wait for the producer to add data before reading it
- Repeat 4 times
Display the time of each addition and reading of data and the status of the buffer)
文件列表:
ex3 - 副本 (0, 2019-03-04)
ex3 - 副本\consumer.cpp (2040, 2018-03-21)
ex3 - 副本\consumer.exe (1856339, 2018-03-21)
ex3 - 副本\main.cpp (2756, 2018-03-21)
ex3 - 副本\main.exe (1855834, 2018-03-21)
ex3 - 副本\pc.c (3735, 2018-03-21)
ex3 - 副本\producer.cpp (1967, 2018-03-21)
ex3 - 副本\producer.exe (1856512, 2018-03-21)
近期下载者:
相关文件:
收藏者: