>> Business Management
For the FIFA World Cup 2006, a fly-over has been constructed between the hotel where the teams are staying and the stadium. This fly-over will be used by the German team and the Italian team in their upcoming exhibition match. A tram car is used to cross this
fly-over, but it seats only four people, and must always carry a full load.
We cannot put three Italians and one German in the same tram-car, because the Italians
would be in majority and might try to intimidate the German. Similarly, we cannot put
three Germans in the same tram-car with one Italian. All other combinations are safe.
You are required to code two processes; the first shall simulate the arrival of German
players and the other the arrival of Italian players. These players can come at any time, in any
order to cross the fly over. The first process shall call a procedure called GermanHere
on the arrival of a German player. Similarly, the second process shall call a procedure
called ItalianHere on the arrival of an Italian athlete. As soon as a safe combination
is reached, the tram starts and crosses to other side. Assume that a tram is always
available when required.
Use semaphores to implement the solution. The Germans and Italians should not wait if
there are enough of them for a safe tram-car load. The two processes will simulate the
arrival of players at random intervals and should run for a while to show around 10 trams
leaving with different safe combinations. Before terminating you must clean up the
semaphores and shared memory segments from the system.
You must output the progress of the processes. E.g. when a player arrives you should
output who arrived and also print the total number of Germans and Italians waiting to
board the tram. When a tram leaves you should output that as well.
Your code should include well written comments and at the beginning, you should
explain your strategy for solving the problem.