Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Theater Simulation A theater is simulated by using threads to model customer and employee behavior. The objective is to use threads for each person and

Theater Simulation A theater is simulated by using threads to model customer and employee behavior. The objective is to use threads for each person and to use semaphores to coordinate their activities. The threads to be used are as follows: Customer: 50 customers are in line at the box office when the simulation starts (1 thread per customer). Movie titles and seats available are read from an input file. Each customer randomly chooses a movie and requests to buy a ticket from the box office. If the movie the customer wants to see is sold out, the customer leaves. The customer must see the ticket taker before entering the theaters main lobby. Each customer randomly chooses whether to visit the concession stand (50% chance to visit it). Each customer randomly visiting the concession stand randomly chooses popcorn, soda, or both. Box Office Agents: Two created initially, one thread each. Serves next customer in line. Maintains count of tickets sold for each moviedoes not sell ticket if movie is sold out. If movie is sold out, this is communicated to the customer. Ticket Taker: Created initially, one thread. Serves next customer in line. Takes and tears ticket. Concession Stand Worker: Created initially, one thread. Serves next customer in line. Gets order from customer. Fills order. Main Creates all threads and joins all customer threads. When last customer has exited, ends the simulation. Other rules: Some actions take time (see table). The thread should sleep 1/60 of the time shown. Each activity of each thread should be printed with identification (e.g., customer 1). A thread may not use sleeping as a means of coordinating with other threads. Busy waiting (polling) is not allowed. Mutual exclusion should be kept to a minimum to allow the most concurrency. The semaphore value may not obtained and used as a basis for program logic. Each thread should print when it is created, and each customer should print when it is joined. All activities of a thread should only be output by that thread.

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions