barber

所属分类:系统编程
开发工具:Visual C++
文件大小:1KB
下载次数:40
上传日期:2010-02-24 11:14:10
上 传 者destiny1891
说明:  睡眠理发师问题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 )

文件列表:
barber.cpp (1512, 2009-12-05)

近期下载者

相关文件


收藏者