Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 types in the 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[NMACHINES] whose elements are non-zero if the corresponding machine is available; NMACHINES is a constant equal to the number of machines there are in the Laundromat, and nfree is a semaphore that indicates the number of available machines.
The code to allocate and release machines is as follows:
synch
The available[] array is initialized to all ones, and semaphore nfree is initialized to NMACHINES. 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?
a.
Implement a lock at the beginning of the allocate function to prevent simultaneous access.
b.
Add a semaphore check before returning the index of an available machine.
c.
Use a loop in the release function to ensure all related variables are properly reset.
d.
Implement a mutex to ensure only one station can access the available machines array at a time.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

What are the cost limitations?

Answered: 1 week ago

Question

Explain the different types of marketing strategies.

Answered: 1 week ago

Question

Explain product positioning.

Answered: 1 week ago

Question

Explain Industrial market segment.

Answered: 1 week ago