ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > zstu-(2021-2022)-1 > student homework directories > 2019333500159厉霖开 >
2019333500159厉霖开Homework6 Version 0
👤 Author: by nintendolinkfoxmailcom 2021-12-27 07:10:42 last modified by nintendolinkfoxmailcom
Q: Propose your own problem which may encounter process synchronization, and use semaphore to solve the problem.

A:

Problem descr iption: Consider a common situation in today's real world. Because of the COVID-19 virus, many restaurants restrict customers to enter the restaurant. Suppose one restaurant has such a method that there's only one customer can enter the restaurant at one time. And if the seat of the restaurant is already full, the customer will leave because it is cold outside.

Problem analysis: Firstly, we use a mutex to ensure that there's only 1 customer can try to sit in a chair in this case. Secondly, we use a semaphore to notify there's a customer come. After the customer come, we can decrease the free seat by one and if the free seat equal to zero, which means there's no free seat, then the customer will leave.

Please login to reply. Login

Reversion History

Loading...
No reversions found.