Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Try to solve this synchronization problem so that all the conditions for proper

ID: 3796152 • Letter: T

Question

Try to solve this synchronization problem so that all the conditions for proper execution are ensured. The passage that connects two areas is only wide enough for one person to pass through. Several people can be in the passage simultaneously, but they must all be going the same direction. People at one end of the passage cannot see the other end. The town will not pay for two ushers 24 hours a day to control traffic in the passage. The central city and entertainment district are on one side and residential areas are on the other. How can we prevent confusion and/or the need to constantly back out of the passage to let someone past? Changing the shape and size of the passage is not an option since the buildings on either side and the passage's cobblestone surface are protected as historically significant. Turn in a solution (partial or complete) and your evaluation of how well it meets each of the conditions for ensuring proper execution.

Explanation / Answer

there the entry into the passage is the critical section.

as we all know critical section can be accessed by only one source at a tme.with out proper communication chaoatic situations occur.

In this case both the parties at both the ends want to enter the passage at the same time leading to a race condition.

The solution to this case may be by synchronizing the hardware,by using locks.

at both the ends there need to be two doors which are closed and opened together by the person entering.When oneside door is opened the other side also gets opened.When one side is closed the other side also gets closed.

At the begining lock is closed or doors are closed

lock=false;

acquire lock()

{ if(lock==false) lock=true;

else

wait;

}

release lock()

{

lock=false;

}

At first lock is false so the party at one end gets the door and opens the door.when the persons are inside the passage

The other side people who are willing to enter the passage see that the door is already open meaning that some body is on the way and they have no other option but wait.

that is if lock=true,wait;

when the journey through the passage has completed the doors are closed.lock is set to false,allowing the other side

person to enter.person releasing the lock and setting it to false again,lock=false.

Both sides have to be given equal importance,so keeping a clock timer the first chance is given to both the parties equally.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote