1.Imagine a very long bridge across the Mississippi River. A car will take upwards of 15 minutes to cross this bridge. Due to construction, the bridge has been reduced to a single lane that has to be shared by traffic in both, the west-east and the east-west direction. It is obviously not possible to allow traffic in both directions simultaneously and so a special traffic control mechanism is installed with the following rules:

a.An arriving car will have to wait if the bridge is currently occupied by one or more cars moving in the opposite direction

b.Multiple cars are allowed to cross the bridge in the same direction (otherwise there would be little bridge utilization and arriving cars would have to wait a long time).

c.In order to avoid starvation, the entry of cars onto the bridge in one direction must be stopped after a batch of k cars has entered the bridge to allow traffic in the opposite direction if there are any cars waiting.

d.If there are no cars, the bridge is open in both directions and the first arriving car will determine the direction of traffic.

Viewing each car as a process that is traveling in West-East (WE) or East-West (EW) direction, develop a MONITOR that implements the rules listed above. You MONITOR must use the monitor procedures Enter_WE(), Enter_EW(), Exit_WE(), Exit_EW(), to be executed when a car enters and exits the bridge. Your solution must show all the necessary MONITOR variables and the condition variables.

Your solution must not unnecessarily restrict vehicles to cross the bridge, must be deadlock free, and must not starve traffic in any direction.

2.Consider a Producer/Consumer scenario that involves the production of car tires that are used in the production of a new vehicle. Clearly, to build a new car, four (4) tires are required in the process. In fact, the process of building a new car must not commence unless there are four tires available. Using SEMAPHORES, develop a solution to the Producer/Consumer problem to solve this problem following the rules below:

a.Multiple producer processes produce new tires, one at a time, and deposits them at a storage facility to be used by consumers to construct new vehicles.

b.Consumers can only start the construction of a new car if they can obtain 4 tires from the storage facility.

c.Both, Producers and Consumers are executing indefinitely.

Your solution must be based on simple SEMAPHORES, must be free of deadlocks, and must follow the rules stated above.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.