Question: NOTE: ITS A PROGRAMMING SOLVING QUESTION SO HAVE TO DO IT BY C LANGUAGE. MAKE SURE UPLOAD THE PROGRAM OUTPUT AS WELL. 3. An old

NOTE: ITS A PROGRAMMING SOLVING QUESTION SO HAVE TO DO IT BY C LANGUAGE. MAKE SURE UPLOAD THE PROGRAM OUTPUT AS WELL.

NOTE: ITS A PROGRAMMING SOLVING QUESTION SO HAVE TO DO IT BY

C LANGUAGE. MAKE SURE UPLOAD THE PROGRAM OUTPUT AS WELL. 3. An

3. An old bridge has only one lane and can only hold at most 3 cars at a time without risking collapse. Write a pthreads program that controls traffic so that at any given time, there are at most 3 cars on the bridge, and all of them are going the same direction. A car calls ArriveBridge when it arrives at the bridge and wants to go in the specified direction (0 or 1); ArriveBridge should not return until the car is allowed to get on the bridge. A car calls ExitBridge when it gets off the bridge, potentially allowing other cars to get on. Don't worry about starving cars trying to go in one direction; just make sure cars are always on the bridge when they can be. To assist your programming here are some suggestions Treat each car as a thread. When a car is on the bridge you can put the thread to sleep for a fixed amount of time (same time for all cars) to simulate the time for a car to drive across * Your program outputs the direction that traffic is moving on the bridge and the driver as each car enters the bridge

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!