文件名称:barber
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:685byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
睡眠理发师问题C++解法,使用信号量,理发座位数可选,理发师只有一个-Using semaphore to solve barbers problem,there’s one barber,infinite customer,and a few waiting position,the number of waiting position is depend on the user.
3 semaphores are involved in the program: m_h,barbers,customers.Barbers is for the hair cutting process,customers
Is for each customer’s arriving process,m_h is for a waiting position counter.There’re 2 more handles:threada,threadb as thread handle.
Whenever a customer arrives,program prints: No.xxx customer is coming.If there exists any empty waiting position,the customer turn into a waiting situation,if not,program prints: No room for No.xxx customer,it s leaving.When the barber finishes a haircut,the barber thread prints: Done!Barber has cut a customer.....,meanwhile,the customer thread also prints: No.xxx customer has finished and leaving.
With a While(1){} structure,the barber thread would never stop .The customer thread has no While() structure but the main function will continually and ramdomly create a customer
3 semaphores are involved in the program: m_h,barbers,customers.Barbers is for the hair cutting process,customers
Is for each customer’s arriving process,m_h is for a waiting position counter.There’re 2 more handles:threada,threadb as thread handle.
Whenever a customer arrives,program prints: No.xxx customer is coming.If there exists any empty waiting position,the customer turn into a waiting situation,if not,program prints: No room for No.xxx customer,it s leaving.When the barber finishes a haircut,the barber thread prints: Done!Barber has cut a customer.....,meanwhile,the customer thread also prints: No.xxx customer has finished and leaving.
With a While(1){} structure,the barber thread would never stop .The customer thread has no While() structure but the main function will continually and ramdomly create a customer
相关搜索: barber problem
理发师问题
(系统自动生成,下载前可以参看下载内容)
下载文件列表
barber.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.