Question: urgent!!!! help me i have 40 minute Problem 2 - Threads and Semaphores: designing a concurrent system The two distant cities North Town and South
urgent!!!! help me i have 40 minute

Problem 2 - Threads and Semaphores: designing a concurrent system The two distant cities North Town and South Town each have a large train station but the two cities are connected by a single-track railroad. To prevent trains from crashing. it is forbidden for two trains traveling in opposite directions to be on the track at the same time. However, it is allowed for several trains to share the track if they all travel in the same direction. We model this scenario with the program below: North-bound trains South-bound trains obtain permission to depart from SouthTown obtas permission to depart from Northfoun 2 travel from SouthTown to NorthTown 2 travel from NorthTown to SouthTown 7 leave the track and arrive in North Town 9 leave the track and arrive in South Town This program is to be executed by an arbitrary number of concurrent threads. Each thread goes in one or the other direction. Your job is to implement the synchronization procedures lie. the four lines in italics) with semaphores and/or shared variables. Propose a java solution using just one semaphore
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
