Question: The Wash - O - Matic Laundromat is a computerized laundry reservation system. As each customer enters, he or she puts coins into slots at
The WashOMatic Laundromat is a computerized laundry reservation system. As each customer enters, he or she puts coins into slots at one of two stations and Time left :: number of washing machines heshe will need. The stations are connected to a central computer that automatically assigns available machines and outputs tokens that identify the machines to be used. The customer puts laundry into the machines and inserts each token into the machine indicated on the token. When a machine finishes its cycle, it informs the computer that it is available again. The computer maintains an array availableMACHINES whose elements are nonzero if the corresponding machine is available; MACHINES is a constant equal to the number of machines there are in the Laundromat, and free is a semaphore that indicates the number of available machines.The code to allocate and release machines is as follows:int allocate Returns index of available machine.int gPafiree;#I Wait until a machine is availablefor Li iNMACHINES; Hif available aavailablereleaseint machine Releases machineavailable machine;Vnfiee;The available array is initialized to all ones, and semaphore nfree is initialized to MACHINES. It seems that if two people make requests at the two stations at the same time, they will occasionally be assigned the same machine. This has resulted in several brawls in the Laundromat, and you have been called in by the owner to fix the problem.Assume that one process handles each customer station,What modification in the code can resolve the issue of multiple customers being assigned the same machine?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
