Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In a playground, there is train that takes passengers for a tour. The train begins the tour only when its full. Assume that, we have
In a playground, there is train that takes passengers for a tour. The train begins the tour only when its full. Assume that, we have number of passengers and only one train. Passengers can go several times for a tour, but every time a passenger wants to go for a tour heshe has to wait and check if there is an empty seat in the train. The train can hold a maximum number of passengers so when the train comes it declares the maximum number. Use semaphore to solve the problem of synchronizing passengers and the train, take the following into consideration: The train starts the tour only when it is full; has passengers when the tour finishes, each passenger gets off the train no passenger is allowed to get off while the train in driving, and cannot request another tour until heshe gets off the train. To manage passengers; assume that there is a queue the queue is managed by the gate keeper of the train passengers checks in onebyone last passenger informs the train that all passengers are in the train to start the tour at the end of the tour, passengers gets off the train onbyone To manage the train when the train arrives the gate, informs the gate keeper that it is ready, in order to let passengers check in block the train from running until it has the number of passengers the train starts the tour when last passenger checks in when the train comes from the tour, it waits until all passengers get off then it can go for another round In your submission, make the following clear shared semaphores; declarations and value assignment, add comment to explain for what each semaphore is used code of the Passenger and the Train, add comment to explain the code chart explaining your solution
In a playground, there is train that takes passengers for a tour. The train begins the tour only when its full. Assume that, we have number of passengers and only one train. Passengers can go several times for a tour, but every time a passenger wants to go for a tour heshe has to wait and check if there is an empty seat in the train. The train can hold a maximum number of passengers so when the train comes it declares the maximum number. Use semaphore to solve the problem of synchronizing passengers and the train, take the following into consideration:
The train starts the tour only when it is full; has passengers
when the tour finishes, each passenger gets off the train
no passenger is allowed to get off while the train in driving, and cannot request another tour until heshe gets off the train.
To manage passengers;
assume that there is a queue
the queue is managed by the gate keeper of the train
passengers checks in onebyone
last passenger informs the train that all passengers are in the train to start the tour
at the end of the tour, passengers gets off the train onbyone
To manage the train
when the train arrives the gate, informs the gate keeper that it is ready, in order to let passengers check in
block the train from running until it has the number of passengers
the train starts the tour when last passenger checks in
when the train comes from the tour, it waits until all passengers get off then it can go for another round
In your submission, make the following clear
shared semaphores; declarations and value assignment, add comment to explain for what each semaphore is used
code of the Passenger and the Train, add comment to explain the code
chart explaining your solution
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started