Another mechanism directly supported by POSIX-compliant operating systems (and then, the Linux kernel) is a message queue. A message queue, in its essence, is a linked list of messages stored in the kernel, where each queue is identified by an ID. In this recipe, we'll rewrite the chat program using a message queue, highlighting the key pros and cons.
Learning how to use message queues
How to do it...
In this section, we'll rewrite the chat program from the Learning how to use FIFO recipe. This will allow you to see, hands-on, similarities and differences between FIFO and a message queue:
- Create a new file called mq_chat_user_1.c, and add the following includes and defines:
#include <stdio.h>
#include...