Menu

[solved] – Question 99352

Shopping at the Mega store
A customer walks into a Mega showroom and browses around the store for a while ((simulated by sleep(random time)) before (s)he finds an item (s)he likes. When a customer does so, (s)he might be a bit undecided if (s)he should buy or not purchase the item (simulate this with yield() twice). Once decided, the customer must go to the floor-clerks and receive a slip with which (s)he can pay for the item and then take it home.
Floor clerks wait (by doing busy waiting) for customers to arrive; then, they help them (in a FCFS order) with whatever information they need. However, floor clerks can only help one customer at a time; therefore, a customer must wait (busy waiting on a shared variable) for an available clerk to help him/her.
After all of the customers are assisted (you should keep track of the number of assisted customers), the floor clerks wait for closing time (sleep(of a long time)).

Expert Answer


OR


Leave a Reply

Your email address will not be published. Required fields are marked *