Changes

Jump to: navigation, search

Queue

12,974 bytes added, 17:08, 3 June 2018
Created page with "'''Home * Programming * Data * Queue''' FILE:Data Queue.svg|border|right|thumb| Queue <ref>[https://en.wikipedia.org/wiki/Queue_(abstract_data_type) Q..."
'''[[Main Page|Home]] * [[Programming]] * [[Data]] * Queue'''

[[FILE:Data Queue.svg|border|right|thumb| Queue <ref>[https://en.wikipedia.org/wiki/Queue_(abstract_data_type) Queue (abstract data type) from Wikipedia]</ref> ]]

A '''Queue''' is a [https://en.wikipedia.org/wiki/List_of_data_structures#Linear_data_structures linear data structure] to [https://en.wikipedia.org/wiki/Collection_%28computing%29 collect] data entities in [https://en.wikipedia.org/wiki/FIFO first in, first out order] (FIFO). The only operations are the addition of entries to the rear terminal position (enqueue) and removal of entries from the front terminal position (dequeue). Queues may be instantiated from (shared) [[Memory|main memory]], and therefor accessed with low [https://en.wikipedia.org/wiki/Latency_%28engineering%29 latency] from various [https://en.wikipedia.org/wiki/Process_%28computing%29 processes] or [https://en.wikipedia.org/wiki/Thread_%28computer_science%29 threads], otherwise their hard- and low-level software implementation is hidden by [https://en.wikipedia.org/wiki/Middleware Middleware] layers. Various free and commercial programming language libraries provide queue implementations. Queuing devices like [https://en.wikipedia.org/wiki/Pipeline_%28software%29 pipes] and [https://en.wikipedia.org/wiki/Internet_socket sockets] are likely associated with a [https://en.wikipedia.org/wiki/Stream_%28computing%29 stream] or [https://en.wikipedia.org/wiki/File_descriptor file descriptor]. However, in memory, a queue might be implemented with an [[Array|array]] (likely fixed sized [https://en.wikipedia.org/wiki/Circular_buffer circular buffer]) or [[Linked List|linked list]].

=Applications=
While there are algorithmic applications within one thread, most queue application are related to [https://en.wikipedia.org/wiki/inter-process_communication inter-process-] or inter-thread communication, and [https://en.wikipedia.org/wiki/Data_buffer buffering] within [[Hardware|hard]]- and [[Software|software]].

==Buffering==
A [https://en.wikipedia.org/wiki/Data_buffer buffer] is used to temporarily keep data while it is being moved from one place to another. A buffer often adjusts timing by implementing a queue or FIFO algorithm in memory, simultaneously writing data into the queue at one rate and reading it at another rate.

Within a [https://en.wikipedia.org/wiki/Physical_Layer physical layer], for instance the [https://en.wikipedia.org/wiki/RS-232 RS-232] (V.24) [https://en.wikipedia.org/wiki/Serial_port serial port] and their electronic circuits, namely [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter universal asynchronous receiver/transmitter] (UART), FIFOs <ref>[http://www.lammertbies.nl/comm/info/serial-uart.html Serial UART, an in depth tutorial]</ref> in hardware are used to relax [https://en.wikipedia.org/wiki/Polling_%28computer_science%29 polling] or [https://en.wikipedia.org/wiki/Interrupt_request interrupt request] handling [https://en.wikipedia.org/wiki/Data_Link_Layer data link layer] from time constrains, which may otherwise yield in possible data overruns and exception handling. Those FIFOs consists of a set of read and write "pointers", [[Sequential Logic|sequential control logic]] with appropriate storage, likely a set of [[Memory#FlipFlop|flip-flops]] or latches.

One application of RS-232 in computer chess is [[Chrilly Donninger|Chrilly Donninger's]] [[Auto232]] Interface to play automatic matches between chess programs on different computers <ref>[http://groups.google.com/group/rec.games.chess.computer/browse_frm/thread/636e82fa68d45aa1# Technische Spezifikation des 232-Protokolls], [[Computer Chess Forums|rgcc]], January 8, 1997</ref>.

==Message Queue==
A [https://en.wikipedia.org/wiki/Message_queue message queue] is used for [https://en.wikipedia.org/wiki/Inter-process_communication inter-process communication], or for inter-thread communication within the same process. Many implementations of message queues work internally within an [https://en.wikipedia.org/wiki/Operating_system operating system] and its [https://en.wikipedia.org/wiki/Graphical_user_interface graphical user interface] like [[Windows]], i.e. to pass hardware events such as [https://en.wikipedia.org/wiki/Mouse_%28computing%29 mouse] and [https://en.wikipedia.org/wiki/Keyboard_%28computing%29 keyboard] inputs to an application. Since events may have different priorities, i.e. keyboard event and paint event as request to re-paint a window, message queues of most often implemented as [[Priority Queue|priority queues]].

Other queue implementations allow the passing of messages between different computer systems, connecting multiple applications and multiple operating systems.

These message queuing systems typically provide enhanced [https://en.wikipedia.org/wiki/Resilience_%28network%29 resilience] functionality and protocols to ensure that messages do not get "lost" in the event of a system failure. It is applied by a [https://en.wikipedia.org/wiki/Message-oriented_middleware message-oriented middleware], i. e. [https://en.wikipedia.org/wiki/RDMA remote direct memory access] of [https://en.wikipedia.org/wiki/Message_Passing_Interface MPI] queues.

==Pipeline==
One related application of a [https://en.wikipedia.org/wiki/Thread_safety thread safe] queue for [https://en.wikipedia.org/wiki/Inter-process_communication inter-process communication] is the [https://en.wikipedia.org/wiki/Pipeline_%28software%29 pipeline]. The concept is mentioned as [http://de.wikipedia.org/wiki/Pipes_und_Filter pipes and filters] [https://en.wikipedia.org/wiki/Pipeline_%28software%29 design pattern]. The information that flows in these pipelines is a stream of records, [[Byte|bytes]] or [[Bit|bits]].

In computer chess protocols like the [[Chess Engine Communication Protocol]] or the [[UCI|Universal Chess Interface]], the communication between [[Engines|engine]] and the [[GUI|graphical user interface]] is likely based on pipelines, redirected from [https://en.wikipedia.org/wiki/Standard_streams standard streams].

==Algorithms==
The [https://en.wikipedia.org/wiki/Breadth-first_search#Algorithm_.28informal.29 informal breadth-first algorithm] requires a queue to traverse all [[Node|nodes]] of a [[Search Tree|tree]]:
# Enqueue the root node.
# Dequeue a node and examine it.
:: If the element sought is found in this node, quit the search and return a result.
:: Otherwise enqueue any successors (the direct child nodes) that have not yet been discovered.
# If the queue is empty, every node on the graph has been examined – quit the search and return "not found".
# Repeat from Step 2.

=See also=
* [[Array]]
* [[Linked List]]
* [[Priority Queue]]
* [[Stack]]

=Publications=
* [[Peter Sanders]] ('''1995'''). ''Fast priority queues for parallel branch-and-bound''. [http://www.informatik.uni-trier.de/~ley/db/conf/irregular/irregular95.html#HoppS95 IRREGULAR 1995]
* [http://www.research.ibm.com/people/m/michael/ Maged M. Michael], [http://www.cs.rochester.edu/~scott/ Michael L. Scott] ('''1996'''). ''Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms''. Department of Computer Science, [https://en.wikipedia.org/wiki/University_of_Rochester University of Rochester], [http://www.cs.rochester.edu/u/scott/papers/1996_PODC_queues.pdf pdf]
* [[Donald Knuth]] ('''1997'''). ''[http://www-cs-faculty.stanford.edu/~knuth/taocp.html The Art of Computer Programming]'', Volume 1: Fundamental Algorithms (Third Edition), Addison-Wesley, ISBN 0-201-89683-4, 2.2.1: Stacks, Queues, and Deques, pp. 238–243.
* [[Mathematician#RPStanley|Richard P. Stanley]] ('''2005'''). ''Queue Problems Revisited''. [http://www-math.mit.edu/~rstan/chess/queue.pdf pdf], [https://en.wikipedia.org/wiki/Chess_problem Chess problem] related <ref>[http://www-math.mit.edu/~rstan/chess/ Chess Problems]</ref>
* [http://www.cs.rice.edu/~wns1/ William N. Scherer III], [https://en.wikipedia.org/wiki/Doug_Lea Doug Lea], [http://www.cs.rochester.edu/~scott/ Michael L. Scott] ('''2009'''). ''Scalable Synchronous Queues''. Communications of the ACM, Vol. 52. No. 5, [http://www.cs.rochester.edu/u/scott/papers/2009_Scherer_CACM_SSQ.pdf pdf]
* [[Mathematician#THCormen|Thomas H. Cormen]], [[Charles Leiserson|Charles E. Leiserson]], [[Ronald L. Rivest]], [[Mathematician#CliffordStein|Clifford Stein]] ('''2009'''). ''[https://en.wikipedia.org/wiki/Introduction_to_Algorithms Introduction to Algorithms, 3rd Edition]''. ISBN 0-262-03384-4. 10.1: Stacks and queues

=External Links=
* [https://en.wikipedia.org/wiki/Queue_(abstract_data_type) Queue (abstract data type) from Wikipedia]
* [http://xlinux.nist.gov/dads//HTML/queue.html queue] from [http://xlinux.nist.gov/dads/ Dictionary of Algorithms and Data Structures] by [http://hissa.nist.gov/~black/ Paul E. Black], [https://en.wikipedia.org/wiki/National_Institute_of_Standards_and_Technology National Institute of Standards and Technology]
* [https://en.wikipedia.org/wiki/FIFO FIFO from Wikipedia]
* [https://en.wikipedia.org/wiki/Double-ended_queue Double-ended queue from Wikipedia]
* [https://en.wikipedia.org/wiki/Named_pipe Named pipe from Wikipedia]
* [https://en.wikipedia.org/wiki/Queueing_theory Queueing theory from Wikipedia]
* [https://en.wikipedia.org/wiki/Hartmann_pipeline Hartmann pipeline from Wikipedia]
* [https://en.wikipedia.org/wiki/Circular_buffer Circular buffer from Wikipedia]
: [[FILE:Ring buffer.svg|none|border|text-bottom|link=http://de.wikipedia.org/wiki/Warteschlange_%28Datenstruktur%29]]

==[[C]]==
* [http://www.gnu.org/s/libc/manual/html_node/Pipes-and-FIFOs.html Pipes and FIFOs] - [[Free Software Foundation#GLIBC|The GNU C Library]]
* [http://www.gnu.org/s/libc/manual/html_node/Sockets.html Sockets] - [[Free Software Foundation#GLIBC|The GNU C Library]]
==[[Cpp|C++]]==
* [http://www.cplusplus.com/reference/stl/queue/ C++ Reference : STL Containers : queue]
* [http://www.sgi.com/tech/stl/queue.html queue<T, Sequence>] from [http://www.sgi.com/tech/stl/index.html Standard Template Library Programmer's Guide]
* [http://doc.qt.nokia.com/4.6/qqueue.html Qt 4.6: QQueue Class Reference]
* [http://www.boost.org/doc/libs/1_43_0/libs/graph/doc/breadth_first_search.html Boost Graph Library: Breadth-First Search]
: [http://www.boost.org/doc/libs/1_42_0/boost/pending/queue.hpp Boost C++ Libraries - boost/pending/queue.hpp]
: [http://www.boost.org/doc/libs/1_43_0/libs/graph/example/dave.cpp Boost C++ Libraries - libs/graph/example/dave.cpp]
* [http://www.drdobbs.com/high-performance-computing/208801974;jsessionid=BVBQM504XGJA1QE1GHPSKH4ATMY32JVN Dr Dobbs - Lock-Free Queues]
==[[Java]]==
* [http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Queue.html Queue (Java 2 Platform SE 5.0)]
* [http://tutorials.jenkov.com/java-io/pipes.html Java IO Tutorial: Pipes]
==[[Perl]]==
* [http://perldoc.perl.org/Thread/Queue.html Thread::Queue - perldoc.perl.org]
==[[Python]]==
* [http://docs.python.org/release/2.5.2/lib/module-Queue.html 5.10 Queue -- A synchronized queue class]
==[[Ruby]]==
* [http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/thread/rdoc/classes/Queue.html Class: Queue]
==[[Tcl-Tk|Tcl]]==
* [http://tcllib.sourceforge.net/doc/queue.html TCLLIB - Tcl Standard Library: struct::queue]
==.NET==
* [http://msdn.microsoft.com/en-us/library/system.collections.queue.aspx Queue Class (System.Collections)] from [http://msdn.microsoft.com/en-us/library/ms123401.aspx MSDN Library]
* [http://www.projectbentley.com/work/chess/lockfreequeue.php CHESS-Lock Free Queue] © [http://www.projectbentley.com/ Michael Bentley] 2009 <ref>[http://research.microsoft.com/en-us/projects/chess/ CHESS - Microsoft Research] a tool for finding and reproducing [https://en.wikipedia.org/wiki/Unusual_software_bug Heisenbugs] in concurrent programs</ref>
==Middleware==
* [https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol Advanced Message Queuing Protocol from Wikipedia]
* [http://www.amqp.org/confluence/display/AMQP/Advanced+Message+Queuing+Protocol Advanced Message Queuing Protocol - Website]
* [https://en.wikipedia.org/wiki/Java_Message_Service Java Message Service]
* [https://en.wikipedia.org/wiki/Open_Message_Queue Open Message Queue from Wikipedia]
* [https://mq.dev.java.net/ Open Message Queue : Open Source Java Message Service (JMS)]
* [https://en.wikipedia.org/wiki/Apache_ActiveMQ Apache ActiveMQ from Wikipedia]
* [http://activemq.apache.org/ Apache ActiveMQ - Index]
* [https://en.wikipedia.org/wiki/JORAM JORAM from Wikipedia]
* [https://en.wikipedia.org/wiki/JBoss_Messaging JBoss Messaging from Wikipedia]
* [http://community.jboss.org/wiki/jbossmessaging JBossMessaging - JBoss Community]
* [https://en.wikipedia.org/wiki/Oracle_Advanced_Queuing Oracle Advanced Queuing from Wikipedia]
* [https://en.wikipedia.org/wiki/IBM_WebSphere_MQ IBM WebSphere MQ from Wikipedia]

=References=
<references />

'''[[Data|Up one Level]]'''

Navigation menu