FIFO (computing and electronics): Difference between revisions
imported>SystemPhantom Undid revision 1291107730 by 113.212.111.133 (talk) |
imported>Lambtron →External links: removed hardware-specific link (used as ref in electronic FIFO article); deleted resulting empty section |
||
| Line 2: | Line 2: | ||
{{more citations needed|date=March 2015}} | {{more citations needed|date=March 2015}} | ||
[[file:Data Queue.svg|thumb|Representation of a FIFO queue]] | [[file:Data Queue.svg|thumb|Representation of a FIFO queue]] | ||
[[file:Fifo queue.png|thumb|Representation of a FIFO queue with enqueue and dequeue operations]] | |||
[[file:Fifo schedule.png|thumb|A FIFO schedule]] | |||
In computing and in [[systems theory]], '''first in, first out''' (the first in is the first out), [[acronym]]ized as '''FIFO''', is a method for organizing the manipulation of a data structure (often, specifically a [[data buffer]]) where the oldest (first) entry, or "head" of the [[Queue (data | In computing and in [[systems theory]], '''first in, first out''' (the first in is the first out), [[acronym]]ized as '''FIFO''', is a method for organizing the manipulation of a data structure (often, specifically a [[data buffer]]) where the oldest (first) entry, or "head" of the [[Queue (abstract data type)|queue]], is processed first. | ||
FIFOs are used for a wide variety of applications. Depending on the application, a FIFO may be implemented in hardware as an electronic logic circuit, or in software. | |||
==Applications== | |||
== Computer | FIFOs are used extensively, in a wide variety of applications. For example, disk controllers use a FIFO as a [[I/O scheduling|disk scheduling]] algorithm to determine the order in which to service disk [[Input/output|I/O]] requests.<ref name="TanenbaumBos2015"/> Communication [[network bridge]]s, [[Network switch|switches]] and [[Network router|routers]] used in [[computer network]]s use FIFOs to hold data packets in route to their next destination; typically at least one FIFO is used per network connection.<ref name="KuroseRoss2006">{{cite book|author1=James F. Kurose|author2=Keith W. Ross|title=Computer Networking: A Top-Down Approach|url=https://books.google.com/books?id=QXIwPwAACAAJ|date=July 2006|publisher=Addison-Wesley|isbn=978-0-321-41849-4}}</ref> FIFOs are used in [[Scheduling (computing)|operating system scheduling]] to give every process [[central processing unit]] (CPU) time in the order in which it is demanded.<ref name="TanenbaumBos2015">{{cite book|author1=Andrew S. Tanenbaum|author2=Herbert Bos|title=Modern Operating Systems|url=https://books.google.com/books?id=9gqnngEACAAJ|year=2015|publisher=Pearson|isbn=978-0-13-359162-0}}</ref> FIFOs are used to buffer digital video and audio streams, to facilitate the exchange of stream data between software or hardware (or both) that would otherwise have incompatible data rates. | ||
[[ | |||
==Software FIFO== | |||
Software FIFOs typically are based on a [[circular buffer]] or [[List (abstract data type)|list]] structure. Most software implementations are not [[thread safe]] and require a locking mechanism to ensure the data structure chain is being manipulated by only one thread at a time. | |||
In computing environments that support the [[pipes and filters|pipes-and-filters]] model for [[interprocess communication]], a FIFO is another name for a [[named pipe]]. | |||
===C++ language example=== | |||
The following code shows a [[linked list]] FIFO [[C++]] language implementation. In practice, a number of list implementations exist, including popular Unix systems C sys/queue.h macros or the C++ [[Standard Template Library|standard library]] std::list template, avoiding the need for implementing the data structure from scratch. | The following code shows a [[linked list]] FIFO [[C++]] language implementation. In practice, a number of list implementations exist, including popular Unix systems C sys/queue.h macros or the C++ [[Standard Template Library|standard library]] std::list template, avoiding the need for implementing the data structure from scratch. | ||
| Line 57: | Line 64: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Electronic FIFO== | |||
{{Main|FIFO (electronic)}} | |||
[[File:ΜPD485505G-25.jpg|thumb|Integrated circuit, 5,048 words by 8 bits FIFO ([[NEC]] D485505g-25)]] | |||
[[FIFO (electronic)|Electronic FIFOs]] are commonly used for buffering and flow control between hardware devices or between software and hardware devices which, over finite intervals, operate at different data rates. | |||
A | A FIFO consists of two counters that serve as read and write memory address registers, a memory array, and status and control logic. The memory typically is dual-ported to allow concurrent FIFO read and write operations, and consists of a [[register file]] or [[dual-ported RAM]] (random access memory). | ||
== See also == | == See also == | ||
* [[FINO]] | * [[FINO]] | ||
* [[Leaky bucket]] approach | |||
* [[Queueing theory]] | * [[Queueing theory]] | ||
* <code>[[SCHED_FIFO]]</code> | * <code>[[SCHED_FIFO]]</code> | ||
| Line 94: | Line 81: | ||
{{Reflist}} | {{Reflist}} | ||
{{Authority control}} | {{Authority control}} | ||
{{Queueing theory}} | {{Queueing theory}} | ||
Latest revision as of 22:53, 12 May 2026
TemplateStyles' src attribute must not be empty.
This article needs additional citations for verification. (March 2015) |
In computing and in systems theory, first in, first out (the first in is the first out), acronymized as FIFO, is a method for organizing the manipulation of a data structure (often, specifically a data buffer) where the oldest (first) entry, or "head" of the queue, is processed first.
FIFOs are used for a wide variety of applications. Depending on the application, a FIFO may be implemented in hardware as an electronic logic circuit, or in software.
Applications
FIFOs are used extensively, in a wide variety of applications. For example, disk controllers use a FIFO as a disk scheduling algorithm to determine the order in which to service disk I/O requests.[1] Communication network bridges, switches and routers used in computer networks use FIFOs to hold data packets in route to their next destination; typically at least one FIFO is used per network connection.[2] FIFOs are used in operating system scheduling to give every process central processing unit (CPU) time in the order in which it is demanded.[1] FIFOs are used to buffer digital video and audio streams, to facilitate the exchange of stream data between software or hardware (or both) that would otherwise have incompatible data rates.
Software FIFO
Software FIFOs typically are based on a circular buffer or list structure. Most software implementations are not thread safe and require a locking mechanism to ensure the data structure chain is being manipulated by only one thread at a time.
In computing environments that support the pipes-and-filters model for interprocess communication, a FIFO is another name for a named pipe.
C++ language example
The following code shows a linked list FIFO C++ language implementation. In practice, a number of list implementations exist, including popular Unix systems C sys/queue.h macros or the C++ standard library std::list template, avoiding the need for implementing the data structure from scratch.
#include <memory>
#include <stdexcept>
using namespace std;
template <typename T>
class FIFO {
struct Node {
T value;
shared_ptr<Node> next = nullptr;
Node(T _value): value(_value) {}
};
shared_ptr<Node> front = nullptr;
shared_ptr<Node> back = nullptr;
public:
void enqueue(T _value) {
if (front == nullptr) {
front = make_shared<Node>(_value);
back = front;
} else {
back->next = make_shared<Node>(_value);
back = back->next;
}
}
T dequeue() {
if (front == nullptr)
throw underflow_error("Nothing to dequeue");
T value = front->value;
front = move(front->next);
return value;
}
};
Electronic FIFO
Electronic FIFOs are commonly used for buffering and flow control between hardware devices or between software and hardware devices which, over finite intervals, operate at different data rates.
A FIFO consists of two counters that serve as read and write memory address registers, a memory array, and status and control logic. The memory typically is dual-ported to allow concurrent FIFO read and write operations, and consists of a register file or dual-ported RAM (random access memory).
See also
- FINO
- Leaky bucket approach
- Queueing theory
SCHED_FIFO
References
- ↑ 1.0 1.1 Andrew S. Tanenbaum; Herbert Bos (2015). Modern Operating Systems. Pearson. ISBN 978-0-13-359162-0.
- ↑ James F. Kurose; Keith W. Ross (July 2006). Computer Networking: A Top-Down Approach. Addison-Wesley. ISBN 978-0-321-41849-4.