FIFO
In computing, FIFO (First-In, First-Out) is a method for processing and organizing data in a strict chronological sequence, where the first element that enters is also the first one to exit. This principle is analogous to a line of people waiting for a service on a "first-come, first-served" basis. The FIFO principle is most commonly implemented using a queue data structure.
How FIFO works
Enqueue: When a new element is added, it is placed at the end (or "rear") of the queue.
Dequeue: When an element is removed, it is taken from the beginning (or "front") of the queue.
FIFO is a fundamental concept used across many areas of computing:
Operating Systems: It is used for CPU scheduling (also called FCFS, or First-Come, First-Served), where processes are executed in the order they arrived. It is also used in page replacement algorithms, although more sophisticated methods are often preferred in modern systems.
Data Buffering: Many devices, such as network routers, bridges, and switches, use FIFO buffers to temporarily store data packets in the order they arrive before transmitting them.
Input/Output (I/O) Management: Disk controllers can use a FIFO algorithm to service disk I/O requests in the order they were received.
Pipes: In inter-process communication, a "named pipe" is also known as a FIFO, as data is read from it in the same order it was written.
Print Queues: A simple, real-world example is a printer queue, where the first document sent to the printer is the first one to be printed.