{"id":439,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:16","modified_gmt":"2020-08-22T20:26:16","slug":"this-is-the-page-title-toplevel-272","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=439","title":{"rendered":"Message Queues"},"content":{"rendered":"\n<title>Message Queues<\/title>\nMessage queues allow one or more processes to write messages that will be\nread by one or more reading processes.\nLinux maintains a list of message queues, the <tt>msgque<\/tt> vector: each element\nof which points to a <tt>msqid_ds<\/tt> data structure that fully describes the message\nqueue. When message queues are created, a new <tt>msqid_ds<\/tt> data structure is\nallocated from system memory and inserted into the vector.\n<p>\n<img decoding=\"async\" src=\"msg.gif\">\n<p>\nFigure: System V IPC Message Queues\n<p>Each <tt>msqid_ds<\/tt>\ndata structure contains an <tt>ipc_perm<\/tt> data structure and pointers\nto the messages entered onto this queue. In addition, Linux keeps queue modification\ntimes such as the last time that this queue was written to and so on. The\n<tt>msqid_ds<\/tt> also contains two wait queues: one for the writers to the queue\nand one for the readers of the queue.\n<p>\nEach time a process attempts to write a message to the write queue, its effective\nuser and group identifiers are compared with the mode in this queue&#8217;s\n<tt>ipc_perm<\/tt> data structure. If the process can write to the queue then the\nmessage may be copied from the process&#8217; address space into a <tt>msg<\/tt>\ndata structure and put at the end of this message queue. Each message is tagged with\nan application specific type, agreed between the cooperating processes. However, there\nmay be no room for the message as Linux restricts the number and length of messages\nthat can be written. In this case the process will be added to this message queue&#8217;s\nwrite wait queue and the scheduler will be called to select a new process to run.\nIt will be awakened when one or more messages have been read from this message queue.\n<p>\nReading from the queue is similar. Again, the process&#8217; access rights to\nthe write queue are checked. A reading process may choose to either get the first\nmessage in the queue regardless of its type or select messages with particular types.\nIf no messages match this criteria the reading process will be added to the message\nqueue&#8217;s read wait queue and the scheduler run. When a new message is written to the\nqueue this process will be awakened and run again.\n<p>\n","protected":false},"excerpt":{"rendered":"<p>Message Queues Message queues allow one or more processes to write messages that will be read by one or more reading processes. Linux maintains a list of message queues, the msgque vector: each element of which points to a msqid_ds &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=439\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-439","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=439"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/439\/revisions"}],"predecessor-version":[{"id":625,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/439\/revisions\/625"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}