Question: Linux C You have an intersection controlled by semaphores. A car may not enter the intersection until the intersection is clear. ADDITIONS: A fire engine
Linux C
You have an intersection controlled by semaphores. A car may not enter the intersection until the intersection is clear. ADDITIONS: A fire engine may not enter the intersection until the intersection is clear. If a fire engine is waiting to enter the intersection, no cars are allowed to enter the intersection. Cars and fire engines remain in the intersection for 1 second (sleep). Note: the car and the fire engine are separate programs; they go through the intersection once. If we want 5 cars to go through the intersection we will start 5 copies of the car program.
a) Write the code for the fire engine. Show the semaphore initialization.
b) Write the code for the car. Do not show the semaphore initialization, I will assume it is the same as for the fire engine, so make sure you use the same variable names for your semaphores.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
