Operating systems Programming
The purpose of this document is to discuss the classes and objects and how they all work together to meet the requirements.
A counter represents a table where the servers will work. Each counter runs as a separate thread. They use a semaphore to make them force to wait. They will only proceed to work when a customer enters the waiting area. By then, they get notified and then proceed to serve the next customer from the waiting area.
A counter will stop if all customers have been served on the entire duration of the simulation.
A waiting area is where incoming customers will sit down and wait for them to be called. The waiting area is protected by a semaphore so that it is being accessed by one thread at a time (Counter and Customer Threads).
Another purpose of a waiting area is to identify the next customer to be served when one of the counters becomes available. The next customer to be processed is the one with the smallest number of orders. Once they are picked by an available counter, they will leave the waiting area and go to the counter. Since the customer is still inside the shop, the number of customers in the shop will still remain the same. The number of customers in the shop will only decrease if the customer leaves the shop which happens when they have received all their orders.
A customer represents an individual person who goes into the shop to buy 1 to 20 burritos. Each customer runs as a separate thread. They come at a random time then go into the waiting area. They will be rejected from the waiting area if it is already full, otherwise, they go in and seat down and wait for a server to call them.
Once a customer is called by a server, their orders will be processed but up to 3 burritos only. If there are more burritos left then they go back to the waiting area. Otherwise, they go to the cashier and do their payment.
After the cashier, they leave the shop. The last customer that leaves the shop will trigger the exit point of the counter (Server) threads.
The cashier is protected by a semaphore to be used by 1 customer at a time only. The cashier is where customers pay before they get out of the shop.
The main class is the entry point of the program. The program can be run in 2 options. The first option is without arguments in which it will use the default configuration. The second option where we can use custom configuration values for simulation.
The default configuration uses 3 counters, 15 customers, and a minimum of 1 burrito order per customer, a maximum of 20 burrito orders per customer, 15 customer limit in the waiting area, and the number of burritos each server can produce for each customer.
The main class will create all threads and run them at the same time. The main class will wait for all these threads to finish before terminating.