ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU class(2019-2020-1) > student directories > 2017329621062 蓝傅晓阳 >
homework-4 Version 0
👤 Author: by 1054089618qqcom 2019-10-06 07:41:46
Problem:

Suppose the driver's activity on the bus is to start the vehicle, drive normally, stop at the station;The conductor's activity is to close the door, sell tickets, open the door.

First, let semaphore S1 and S2:

S1 indicates whether the driver is allowed to start the car. The initial value is 0.

S2 indicates whether the conductor is allowed to open the door, with an initial value of 0.

driver(){

P(S1);

start the vehicle;

drive normally;

stop at the station;

V(S2);

}

conductor(){

close the door;

V(S1);

sell tickets;

P(S2)

open the door;

}

Please login to reply. Login

Reversion History

Loading...
No reversions found.