A queue is a fundamental linear data structure that follows the First-In, First-Out (FIFO) principle. This means that the first element added to the queue is the first one removed, similar to a line of people waiting for service. Queues rely on two primary operations: enqueue, which adds an element to the rear (end), and dequeue, which removes an element from the front (head). This structure is essential in programming for managing tasks and data that require sequential processing.
For example, operating systems use queues to manage print jobs, ensuring documents are printed in the order received. In instrument control applications, queues are vital for managing command sequences sent to programmable power supplies. A control program can enqueue a series of instructions (e.g., "set voltage to 5V", "wait 1 second", "set voltage to 10V"). The system then retrieves and executes these commands one by one, ensuring precise operational sequence. This differs from a stack, which operates on a Last-In, First-Out (LIFO) principle.