Queue


Definition
A Queue is an ordered collection of items in which the items are inserted from one end called the front end and the items are deleted from the other end called the rear end.


Applications:
CPU Scheduling
The CPU scheduling algorithms use the FIFO method for issuing the processor for the waiting processes.
Routers
The routers used in Networking use Queues to store and forward the data bits from and to computers or other devices.
Messaging
Queues are extensively used in Messaging. Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: A messaging client can send messages to, and receive messages from, any other client. Each client connects to a messaging agent that provides facilities for creating, sending, receiving, and reading messages.
Examples of commercial implementations: IBM's WMQ, Microsoft's MSMQ, Oracle's Advanced Queueing, BEA's WebLogic etc. Some open source implementations: JBoss Messaging, JORAM, ActiveMQ, Open Message Queue, RabbitMQ, ISectd, Skytools PgQ, Apache Qpid etc...

Predefined
#define QUEUE_SIZE 50
int q[QUEUE_SIZE];
int front;
int rear;
front = rear = -1;

FUNCTIONS
Basic Operations
int IsEmpty(int q[], int front);
int IsFull(int q[], int rear);
int Insert(int q[], int *front, int *rear, int item);
int Delete(int q[], int *front, int *rear, int *item);
int Peek(int q[], int front, int *item);
int Display(int q[], int front, int rear);