Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Message queue
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Implementation in UNIX== There are two common message queue implementations in [[Unix|UNIX]]. One is part of the SYS V API, the other one is part of [[POSIX]]. ===SYS V=== UNIX SYS V implements message passing by keeping an array of linked lists as message queues. Each message queue is identified by its index in the array, and has a unique descriptor. A given index can have multiple possible descriptors. UNIX gives standard functions to access the message passing feature.<ref name="The Design of the UNIX Operating System"> {{cite book | title=The Design of the UNIX Operating System | author=Bach, M.J. | year=1986 | publisher=Prentice-Hall | isbn=9780132017992 | url-access=registration | url=https://archive.org/details/designofunixoper00bach }} </ref> ;<code>msgget()</code>: This system call takes a key as an argument and returns a descriptor of the queue with the matching key if it exists. If it does not exist, and the <code>IPC_CREAT</code> flag is set, it makes a new message queue with the given key and returns its descriptor. ;<code>msgrcv()</code>: Used to receive a message from a given queue descriptor. The caller process must have read permissions for the queue. It is of two types.<ref name="Operating Systems Concepts"> {{cite book | title=Operating Systems Concepts |author=Abraham Silberschatz, Peter B. Galvin |year=1994 |publisher=Addison-Wesley | isbn=9780201504804 }} </ref> :*Blocking receive puts the child to sleep if it cannot find a requested message type. It sleeps until another message is posted in the queue, and then wakes up to check again. :*Non-blocking receive returns immediately to the caller, mentioning that it failed. ;<code>msgctl()</code>: Used to change message queue parameters like the owner. Most importantly, it is used to delete the message queue by passing the <code>IPC_RMID</code> flag. A message queue can be deleted only by its creator, owner, or the superuser. ===POSIX=== The POSIX.1-2001 message queue API is the later of the two UNIX message queue APIs. It is distinct from the SYS V API, but provides similar function. The unix man page <code>mq_overview(7)</code> provides an overview of POSIX message queues.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)