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 Wash-O-Matic 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 0:51:48 number of washing machines he/she 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 available[MACHINES] whose elements are non-zero 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 gP(afiree);#I Wait until a machine is availablefor Li-0, iNMACHINES; (H)if (available (a]1-0)available(0-0,release(int machine)// Releases machine{available [machine]-1;V(nfiee);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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!