I am new to programming and computer systems.I found this question in an old textbook and I am really interested in it, yet finding it difficult. If anyone could help with any pointers or psudo-code to work out the problem.
Question 10:
A harbour serves two purposes for passing ships: a loading/offloading dock for cargo ships, and a maintenance dock for service and repair of cargo ships.
There is one two-lane channel leading from the ocean to the harbour: one for incoming ships, and one for outgoing ships. Two tug-boats patrol the channel : one for ships that are waiting to come into the harbour to load/offload, and one to lead ships from the maintenance dock back to sea. Each lane can, therefore only service one ingoing ship and one outgoing ship at a time.
The loading dock can host five ships at a time, and there are three fork-lifts to do the work, so three ships can be loaded/unloaded simultaneously. Fork-lifts either load/unload or they are parked.
With the reasoning that servicing will be quicker than loading, the maintenance dock can host three ships for repair, service, or bypass (nothing required). There is only one team of mechanics, so one ship can be serviced/repaired/bypassed at a time. The mechanics either service/repair/bypass, or they rest. There is a single-lane channel from the loading dock to the maintenance dock.
All ships enter to: load/offload, and then service/repair. i.e. a ship enters, goes to loading dock, goes to maintenance dock, and then exits the harbour.
Model the above synchronization problem as FIVE processes:
-
a ship
-
incoming tug-boat
-
a fork-lift
-
the mechanic-team
-
outgoing tugboat.
*Notes:Use semaphores and shared memory to model shared resources, and synchronized access to them
Aucun commentaire:
Enregistrer un commentaire