The people waiting to get food would be your queue. The first person in line is the first one served. First in, first out
maintains a queue of print jobs
maintains a queue od disk input/output requests
3.Schedular(e.g, in operating system):
maintains a queue of processes awaiting a slice of machine time.
The major application of queue is in the operating system and in networks. All the processes that are submitted to your processor or thr CPU are first taken in a queue which are then processed as pewr various algorithms.
Similarly on a network if a number of users want to access a resource their request is taken in a queue and then processed.
Queue application In C Posted by apple9966 on 12 Aug 2008 at 2:09 AM
In general all fast food chains like McDonalds, Subway, and other drive-ins follow queue model to take the order and serve. When a user enters the desk, his order is pushed into the system. The stewards, cook/arrange the order based on the queue inside kitchen
. Once the order is prepared, it will dequeued of kitchen queue.
1. Let us consider a queue of 10. More than 10 display queue is full message.
2. Customer approach different desks/counters at same time. In each counter they are asked for the order. Entire order details are stored in a data structure and pushed/enqueued into the kitchen queue.
3. Every order is at service desk. Amount of their order is mentioned at the end. For this we need list of items and their respective prices are stored in item list. At the end of the order the total amount is calculated. At payment, let us assume same order is reflected in the kitchen. This is one push operation.
4. The values inside queue elements would be the order and the quantity.
5. Once the order is prepared and delivered a pop/dequeue operation removes the front order and stores them in a file with a transaction number.
6. Until the front order is complete. Order is not popped out/dequeued. When the queue of 10 is not served that means the queue is full. The desks have to wait
7. Simulate desks scenarios using a random number mod 3/4 operation representing each desk. And these orders are placed in the queue based on the order generated by random number.