操作系统实验二:进程、线程之间的同步

上传者: zhiqun5624265 | 上传时间: 2019-12-21 22:20:40 | 文件大小: 11.43MB | 文件类型: rar
1。生产者消费者问题(信号量+mutex) 参考教材中的生产者消费者算法,创建5个进程,其中两个进程为生产者进程,3个进程为消费者进程。一个生产者进程试图不断地在一个缓冲中写入大写字母,另一个生产者进程试图不断地在缓冲中写入小写字母。3个消费者不断地从缓冲中读取一个字符并输出。为了使得程序的输出易于看到结果,仿照阅读材料中的实例程序,分别在生产者和消费者进程的合适的位置加入一些随机睡眠时间。 可选的实验:在上面实验的基础上实现部分消费者有选择地消费某些产品。例如一个消费者只消费小写字符,一个消费者只消费大写字母,而另一个消费者则无选择地消费任何产品。消费者要消费的产品没有时,消费者进程被阻塞。注意缓冲的管理。 2。用信号量和mutex方式实现睡觉的理发师问题 3。读者写者问题 教材和相关的阅读材料中对读者写者问题算法均有描述,但这个算法在不断地有读者流的情况下,写者会被阻塞。编写一个写者优先解决读者写者问题的程序,其中读者和写者均是多个进程,用信号量作为同步互斥机制。

文件下载

资源详情

[{"title":"( 82 个子文件 11.43MB ) 操作系统实验二:进程、线程之间的同步","children":[{"title":"实验二","children":[{"title":"生产者消费者","children":[{"title":"producer-consumer","children":[{"title":"producer-consumer.suo <span style='color:#111;'> 19.50KB </span>","children":null,"spread":false},{"title":"producer-consumer","children":[{"title":"producer-consumer.idc <span style='color:#111;'> 757B </span>","children":null,"spread":false},{"title":"temp.txt <span style='color:#111;'> 2B </span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"producer-consumer.exe.intermediate.manifest <span style='color:#111;'> 145B </span>","children":null,"spread":false},{"title":"BuildLog.htm <span style='color:#111;'> 5.78KB </span>","children":null,"spread":false},{"title":"mt.dep <span style='color:#111;'> 67B </span>","children":null,"spread":false},{"title":"vc80.idb <span style='color:#111;'> 107.00KB </span>","children":null,"spread":false},{"title":"producer-consumer.obj <span style='color:#111;'> 2.37KB </span>","children":null,"spread":false}],"spread":true},{"title":"producer-consumer.cpp <span style='color:#111;'> 1.10KB </span>","children":null,"spread":false},{"title":"producer-consumer.vcproj.77A9D0331CA8430.Administrator.user <span style='color:#111;'> 1.39KB </span>","children":null,"spread":false},{"title":"producer-consumer.vcproj <span style='color:#111;'> 2.99KB </span>","children":null,"spread":false}],"spread":true},{"title":"producer-consumer.sln <span style='color:#111;'> 916B </span>","children":null,"spread":false},{"title":"producer-consumer.ncb <span style='color:#111;'> 8.89MB </span>","children":null,"spread":false},{"title":"debug","children":[{"title":"producer-consumer.exe <span style='color:#111;'> 56.00KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"main","children":[{"title":"main.sln <span style='color:#111;'> 877B </span>","children":null,"spread":false},{"title":"main","children":[{"title":"main.cpp <span style='color:#111;'> 3.74KB </span>","children":null,"spread":false},{"title":"main.vcproj <span style='color:#111;'> 2.96KB </span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"BuildLog.htm <span style='color:#111;'> 9.97KB </span>","children":null,"spread":false},{"title":"main.exe.intermediate.manifest <span style='color:#111;'> 145B </span>","children":null,"spread":false},{"title":"mt.dep <span style='color:#111;'> 67B </span>","children":null,"spread":false},{"title":"main.obj <span style='color:#111;'> 6.33KB </span>","children":null,"spread":false},{"title":"vc80.idb <span style='color:#111;'> 107.00KB </span>","children":null,"spread":false}],"spread":true},{"title":"main.vcproj.77A9D0331CA8430.Administrator.user <span style='color:#111;'> 1.39KB </span>","children":null,"spread":false}],"spread":true},{"title":"main.suo <span style='color:#111;'> 13.00KB </span>","children":null,"spread":false},{"title":"main.ncb <span style='color:#111;'> 8.89MB </span>","children":null,"spread":false},{"title":"debug","children":[{"title":"main.exe <span style='color:#111;'> 68.00KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"读者写者","children":[{"title":"main","children":[{"title":"main.sln <span style='color:#111;'> 878B </span>","children":null,"spread":false},{"title":"main","children":[{"title":"main.cpp <span style='color:#111;'> 1.20KB </span>","children":null,"spread":false},{"title":"main.vcproj.8.00.old <span style='color:#111;'> 2.96KB </span>","children":null,"spread":false},{"title":"main.vcproj <span style='color:#111;'> 3.03KB </span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"vc90.idb <span style='color:#111;'> 123.00KB </span>","children":null,"spread":false},{"title":"BuildLog.htm <span style='color:#111;'> 5.81KB </span>","children":null,"spread":false},{"title":"main.exe.intermediate.manifest <span style='color:#111;'> 381B </span>","children":null,"spread":false},{"title":"mt.dep <span style='color:#111;'> 65B </span>","children":null,"spread":false},{"title":"main.obj <span style='color:#111;'> 2.10KB </span>","children":null,"spread":false},{"title":"vc80.idb <span style='color:#111;'> 107.00KB </span>","children":null,"spread":false}],"spread":true},{"title":"main.vcproj.zhiqun-PC.zhiqun.user <span style='color:#111;'> 1.38KB </span>","children":null,"spread":false},{"title":"main.vcproj.77A9D0331CA8430.Administrator.user <span style='color:#111;'> 1.39KB </span>","children":null,"spread":false}],"spread":true},{"title":"_UpgradeReport_Files","children":[{"title":"UpgradeReport.xslt <span style='color:#111;'> 12.21KB </span>","children":null,"spread":false},{"title":"UpgradeReport_Plus.gif <span style='color:#111;'> 71B </span>","children":null,"spread":false},{"title":"UpgradeReport.css <span style='color:#111;'> 3.27KB </span>","children":null,"spread":false},{"title":"UpgradeReport_Minus.gif <span style='color:#111;'> 69B </span>","children":null,"spread":false}],"spread":true},{"title":"main.sln.old <span style='color:#111;'> 877B </span>","children":null,"spread":false},{"title":"main.suo.old <span style='color:#111;'> 8.50KB </span>","children":null,"spread":false},{"title":"main.suo <span style='color:#111;'> 9.00KB </span>","children":null,"spread":false},{"title":"main.ncb <span style='color:#111;'> 10.25MB </span>","children":null,"spread":false},{"title":"UpgradeLog.XML <span style='color:#111;'> 2.37KB </span>","children":null,"spread":false},{"title":"debug","children":[{"title":"main.exe <span style='color:#111;'> 48.50KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"reader_writer","children":[{"title":"reader_writer.sln.old <span style='color:#111;'> 904B </span>","children":null,"spread":false},{"title":"_UpgradeReport_Files","children":[{"title":"UpgradeReport.xslt <span style='color:#111;'> 12.21KB </span>","children":null,"spread":false},{"title":"UpgradeReport_Plus.gif <span style='color:#111;'> 71B </span>","children":null,"spread":false},{"title":"UpgradeReport.css <span style='color:#111;'> 3.27KB </span>","children":null,"spread":false},{"title":"UpgradeReport_Minus.gif <span style='color:#111;'> 69B </span>","children":null,"spread":false}],"spread":true},{"title":"reader_writer.sln <span style='color:#111;'> 905B </span>","children":null,"spread":false},{"title":"reader_writer.suo.old <span style='color:#111;'> 7.50KB </span>","children":null,"spread":false},{"title":"reader_writer.suo <span style='color:#111;'> 9.00KB </span>","children":null,"spread":false},{"title":"reader_writer","children":[{"title":"reader_writer.vcproj.77A9D0331CA8430.Administrator.user <span style='color:#111;'> 1.39KB </span>","children":null,"spread":false},{"title":"reader_writer.cpp <span style='color:#111;'> 1.34KB </span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"vc90.idb <span style='color:#111;'> 123.00KB </span>","children":null,"spread":false},{"title":"BuildLog.htm <span style='color:#111;'> 6.31KB </span>","children":null,"spread":false},{"title":"mt.dep <span style='color:#111;'> 65B </span>","children":null,"spread":false},{"title":"reader_writer.exe.intermediate.manifest <span style='color:#111;'> 381B </span>","children":null,"spread":false},{"title":"vc80.idb <span style='color:#111;'> 107.00KB </span>","children":null,"spread":false},{"title":"reader_writer.obj <span style='color:#111;'> 1.95KB </span>","children":null,"spread":false}],"spread":true},{"title":"reader_writer.vcproj.zhiqun-PC.zhiqun.user <span style='color:#111;'> 1.38KB </span>","children":null,"spread":false},{"title":"reader_writer.vcproj.8.00.old <span style='color:#111;'> 2.98KB </span>","children":null,"spread":false},{"title":"reader_writer.vcproj <span style='color:#111;'> 3.04KB </span>","children":null,"spread":false}],"spread":true},{"title":"reader_writer.ncb <span style='color:#111;'> 10.25MB </span>","children":null,"spread":false},{"title":"UpgradeLog.XML <span style='color:#111;'> 2.64KB </span>","children":null,"spread":false},{"title":"debug","children":[{"title":"reader_writer.exe <span style='color:#111;'> 45.50KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"理发师","children":[{"title":"barber","children":[{"title":"barber.suo <span style='color:#111;'> 8.00KB </span>","children":null,"spread":false},{"title":"barber.ncb <span style='color:#111;'> 9.25MB </span>","children":null,"spread":false},{"title":"barber.sln <span style='color:#111;'> 883B </span>","children":null,"spread":false},{"title":"barber","children":[{"title":"barber.vcproj.77A9D0331CA8430.Administrator.user <span style='color:#111;'> 1.39KB </span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"barber.exe.intermediate.manifest <span style='color:#111;'> 145B </span>","children":null,"spread":false},{"title":"BuildLog.htm <span style='color:#111;'> 5.13KB </span>","children":null,"spread":false},{"title":"mt.dep <span style='color:#111;'> 67B </span>","children":null,"spread":false},{"title":"haircut.obj <span style='color:#111;'> 2.82KB </span>","children":null,"spread":false},{"title":"vc80.idb <span style='color:#111;'> 107.00KB </span>","children":null,"spread":false}],"spread":true},{"title":"haircut.cpp <span style='color:#111;'> 1.48KB </span>","children":null,"spread":false},{"title":"barber.vcproj <span style='color:#111;'> 2.97KB </span>","children":null,"spread":false}],"spread":true},{"title":"debug","children":[{"title":"barber.exe <span style='color:#111;'> 56.00KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true}]

评论信息

  • lz12wl :
    很不错的,值得学习
    2014-12-15
  • wxj66666628 :
    生产者消费者问题
    2014-06-18
  • h08997jp :
    资源还行,不过版本略旧.
    2014-06-17
  • 悠然_若梦 :
    还行,但是是windows系统下的
    2013-10-21
  • tuniutu :
    很详细,都可以用,就是代码要有些解释更好理解
    2012-12-13

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明