文件名称:BarberAndCustomer
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:3.27mb
-
已下载:1次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
1)用C语言或C++语言编程实现P、V原语并用P、V原语描述如下生产者-消费者问题:
有一个理发师,一把理发椅和n把提供给等候理发的顾客座的椅子。如果没有顾客,则理发师便在理发椅子上睡觉;当第一个顾客到来时,必须唤醒该理发师进行理发;如果理发师正在理发时又有顾客到来,则如果有空椅子可坐,他就坐下来等待,如果没有空椅子,他就离开理发店。
为理发师和顾客各编一段程序描述他们的行为,要求不能带有竞争条件,试用P、V操作实现。
(2)分析
此题可看作是n个生产者和1个消费者问题。
顾客作为生产者,每到来一个就使计数器rc增加1,以便让理发师理发(相当于消费)至最后一个顾客(相当于产品)。并且,第1个到来的顾客应负责唤醒理发师;如果不是第1个到达的顾客,则在有空椅子的情况下坐下等待,否则离开理发店(该消息可由计数器rc获得)。
有一个理发师,一把理发椅和n把提供给等候理发的顾客座的椅子。如果没有顾客,则理发师便在理发椅子上睡觉;当第一个顾客到来时,必须唤醒该理发师进行理发;如果理发师正在理发时又有顾客到来,则如果有空椅子可坐,他就坐下来等待,如果没有空椅子,他就离开理发店。
为理发师和顾客各编一段程序描述他们的行为,要求不能带有竞争条件,试用P、V操作实现。
(2)分析
此题可看作是n个生产者和1个消费者问题。
顾客作为生产者,每到来一个就使计数器rc增加1,以便让理发师理发(相当于消费)至最后一个顾客(相当于产品)。并且,第1个到来的顾客应负责唤醒理发师;如果不是第1个到达的顾客,则在有空椅子的情况下坐下等待,否则离开理发店(该消息可由计数器rc获得)。
(系统自动生成,下载前可以参看下载内容)
下载文件列表
BarberAndCustomer/Barber/barber.cpp
BarberAndCustomer/Barber/Barber.vcproj
BarberAndCustomer/Barber/Barber.vcproj.MICROSOF-5AF945.Administrator.user
BarberAndCustomer/Barber/Debug/Barber.exe.embed.manifest
BarberAndCustomer/Barber/Debug/Barber.exe.embed.manifest.res
BarberAndCustomer/Barber/Debug/Barber.exe.intermediate.manifest
BarberAndCustomer/Barber/Debug/barber.obj
BarberAndCustomer/Barber/Debug/BuildLog.htm
BarberAndCustomer/Barber/Debug/mt.dep
BarberAndCustomer/Barber/Debug/vc90.idb
BarberAndCustomer/Barber/Debug/vc90.pdb
BarberAndCustomer/BarberAndCustomer.ncb
BarberAndCustomer/BarberAndCustomer.sln
BarberAndCustomer/BarberAndCustomer.suo
BarberAndCustomer/Customer/Customer.cpp
BarberAndCustomer/Customer/Customer.vcproj
BarberAndCustomer/Customer/Customer.vcproj.MICROSOF-5AF945.Administrator.user
BarberAndCustomer/Customer/Debug/BuildLog.htm
BarberAndCustomer/Customer/Debug/Customer.exe.embed.manifest
BarberAndCustomer/Customer/Debug/Customer.exe.embed.manifest.res
BarberAndCustomer/Customer/Debug/Customer.exe.intermediate.manifest
BarberAndCustomer/Customer/Debug/Customer.obj
BarberAndCustomer/Customer/Debug/mt.dep
BarberAndCustomer/Customer/Debug/vc90.idb
BarberAndCustomer/Customer/Debug/vc90.pdb
BarberAndCustomer/Debug/Barber.exe
BarberAndCustomer/Debug/Barber.ilk
BarberAndCustomer/Debug/Barber.pdb
BarberAndCustomer/Debug/Customer.exe
BarberAndCustomer/Debug/Customer.ilk
BarberAndCustomer/Debug/Customer.pdb
BarberAndCustomer/Debug/QueueCustomer.dll
BarberAndCustomer/Debug/QueueCustomer.exp
BarberAndCustomer/Debug/QueueCustomer.ilk
BarberAndCustomer/Debug/QueueCustomer.lib
BarberAndCustomer/Debug/QueueCustomer.pdb
BarberAndCustomer/Instruction.txt
BarberAndCustomer/QueueCustomer/Debug/BuildLog.htm
BarberAndCustomer/QueueCustomer/Debug/mt.dep
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.dll.embed.manifest
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.dll.embed.manifest.res
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.dll.intermediate.manifest
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.obj
BarberAndCustomer/QueueCustomer/Debug/vc90.idb
BarberAndCustomer/QueueCustomer/Debug/vc90.pdb
BarberAndCustomer/QueueCustomer/QueueCustomer.cpp
BarberAndCustomer/QueueCustomer/QueueCustomer.h
BarberAndCustomer/QueueCustomer/QueueCustomer.vcproj
BarberAndCustomer/QueueCustomer/QueueCustomer.vcproj.MICROSOF-5AF945.Administrator.user
BarberAndCustomer/Barber/Debug
BarberAndCustomer/Customer/Debug
BarberAndCustomer/QueueCustomer/Debug
BarberAndCustomer/Barber
BarberAndCustomer/Customer
BarberAndCustomer/Debug
BarberAndCustomer/QueueCustomer
BarberAndCustomer
BarberAndCustomer/Barber/Barber.vcproj
BarberAndCustomer/Barber/Barber.vcproj.MICROSOF-5AF945.Administrator.user
BarberAndCustomer/Barber/Debug/Barber.exe.embed.manifest
BarberAndCustomer/Barber/Debug/Barber.exe.embed.manifest.res
BarberAndCustomer/Barber/Debug/Barber.exe.intermediate.manifest
BarberAndCustomer/Barber/Debug/barber.obj
BarberAndCustomer/Barber/Debug/BuildLog.htm
BarberAndCustomer/Barber/Debug/mt.dep
BarberAndCustomer/Barber/Debug/vc90.idb
BarberAndCustomer/Barber/Debug/vc90.pdb
BarberAndCustomer/BarberAndCustomer.ncb
BarberAndCustomer/BarberAndCustomer.sln
BarberAndCustomer/BarberAndCustomer.suo
BarberAndCustomer/Customer/Customer.cpp
BarberAndCustomer/Customer/Customer.vcproj
BarberAndCustomer/Customer/Customer.vcproj.MICROSOF-5AF945.Administrator.user
BarberAndCustomer/Customer/Debug/BuildLog.htm
BarberAndCustomer/Customer/Debug/Customer.exe.embed.manifest
BarberAndCustomer/Customer/Debug/Customer.exe.embed.manifest.res
BarberAndCustomer/Customer/Debug/Customer.exe.intermediate.manifest
BarberAndCustomer/Customer/Debug/Customer.obj
BarberAndCustomer/Customer/Debug/mt.dep
BarberAndCustomer/Customer/Debug/vc90.idb
BarberAndCustomer/Customer/Debug/vc90.pdb
BarberAndCustomer/Debug/Barber.exe
BarberAndCustomer/Debug/Barber.ilk
BarberAndCustomer/Debug/Barber.pdb
BarberAndCustomer/Debug/Customer.exe
BarberAndCustomer/Debug/Customer.ilk
BarberAndCustomer/Debug/Customer.pdb
BarberAndCustomer/Debug/QueueCustomer.dll
BarberAndCustomer/Debug/QueueCustomer.exp
BarberAndCustomer/Debug/QueueCustomer.ilk
BarberAndCustomer/Debug/QueueCustomer.lib
BarberAndCustomer/Debug/QueueCustomer.pdb
BarberAndCustomer/Instruction.txt
BarberAndCustomer/QueueCustomer/Debug/BuildLog.htm
BarberAndCustomer/QueueCustomer/Debug/mt.dep
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.dll.embed.manifest
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.dll.embed.manifest.res
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.dll.intermediate.manifest
BarberAndCustomer/QueueCustomer/Debug/QueueCustomer.obj
BarberAndCustomer/QueueCustomer/Debug/vc90.idb
BarberAndCustomer/QueueCustomer/Debug/vc90.pdb
BarberAndCustomer/QueueCustomer/QueueCustomer.cpp
BarberAndCustomer/QueueCustomer/QueueCustomer.h
BarberAndCustomer/QueueCustomer/QueueCustomer.vcproj
BarberAndCustomer/QueueCustomer/QueueCustomer.vcproj.MICROSOF-5AF945.Administrator.user
BarberAndCustomer/Barber/Debug
BarberAndCustomer/Customer/Debug
BarberAndCustomer/QueueCustomer/Debug
BarberAndCustomer/Barber
BarberAndCustomer/Customer
BarberAndCustomer/Debug
BarberAndCustomer/QueueCustomer
BarberAndCustomer
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.