homework - 4 Version 0 |
|
👤 Author: by 1258995450qqcom 2019-10-09 10:31:33 |
1, set the bus, the driver and the conductor are respectively:
Driver's activities:
Start the vehicle;
Normal driving;
Stop at the station;
Conductor's activities:
Shut the door;
The ticket;
The car door open;
What is the synchronous relationship between the two activities as the car continues to arrive, stop and move?P, V operation to achieve their synchronization.
Solution: set two semaphores S and C with initial value S = 0.C = 0;
Driver: English: normal conductor: L2: ticket
As the P (S)
V (S) drive door
P (C) shut the door
Start driving V (C)
GO TO L1 GO TO L2
Please login to reply. Login