Two Way North South Highway Mountains Must Pass Narrow Tunnel One Lane South Bound North B Q30914439

A two-way north-south highway through the mountains must pass
through a narrow tunnel with only one lane. A south-bound or
north-bound car can pass through the tunnel only if, when itarrives,
there are no on-comming cars in the tunnel. Note, due to the
length of the tunnel, at most only 3 cars are allowed in thetunnel
at one time—provided that they are all heading in the same
In pseudo-code write the two processes north2south andsouth2north
that allows cars to use the tunnel safely. As a starting pointuse
the code below.

Remember: All Semaphores and variables must be initialised.
/* Shared Data between all processes */
Semaphore tunnel_mutex;
/* Shared Data between south2north processes */
Semaphore north_mutex;
Semaphore going_north_max;
int number_going_north;
/* Add Synchronisation code here */
/* Add Synchronisation code here */
/* Shared Data between north2south processes */
Semaphore south_mutex;
Semaphore going_south_max;
int number_going_south;
/* Add Synchronisation code here */
/* Add Synchronisation code here */

"We Offer Paper Writing Services on all Disciplines, Make an Order Now and we will be Glad to Help"
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.