ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU class(2019-2020-1) > student directories > >
homework-4 Version 0
👤 Author: by 819755696qqcom 2019-10-05 03:01:13
Problem:
There's a very remote scenic spot that few people visit.
It is always a very troublesome thing to provide ticket-buying service. To alleviate staff burden
and the pressure of scenic spots, only when there is a queue, tickets will be sold and only when
the number of people reaches a certain level can they be allowed to enter the scenic area..

Solution:
Set two semaphores S and C, the initial value is S=0; C=0;
We call the tourist L1, ticket Office L2 in this problem

L1:                                             L2:
1、Line up                               1、P(S)
2、V(S)                                    2、Open door
3、P(C)                                    3、Sell ticket
4、Entering scenic spots     4、V(C)

Please login to reply. Login

Reversion History

Loading...
No reversions found.