Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.5 kB
2
Indexable
Never
Objective: Develop a program to simulate a railway system where trains (threads) pass through a shared railway track (critical section), controlled by semaphores. Background: This problem demonstrates the use of semaphores to manage access to a shared resource (railway track) in a scenario where multiple entities (trains) require access. Problem Statement: Create a simulation of a railway system where multiple trains need to pass through a shared track section. Use semaphores to ensure that only one train occupies the shared track section at any given time. Requirements:Train Threads: ● Simulate trains as threads that need to pass through the shared track section. ● Trains arrive at and leave the track section at random intervals.Shared Track Management: ● Implement the shared track section as a critical section in your program. ● Use a semaphore to control access to this section.Safety Synchronization: ● Ensure that no two trains are on the shared track section simultaneously. ● Implement additional safety measures like signaling train entry and exit.Concurrency and Deadlock Avoidance: ● Handle potential deadlocks and ensure fair access for all trains. ● Log train movements and semaphore states. Evaluation Criteria: ● Effective use of semaphores for track access synchronization. ● Prevention of deadlocks and safe train passage. ● Accurate logging of train movements and semaphore states. ● Code clarity and comprehensive documentation.
Leave a Comment