EmbeddedPathashala · TLPI Series · Chapter 46
System V Message Queues
Inter-Process Communication · Kernel IPC · msgget · msgsnd · msgrcv · msgctl
What is this chapter about?
System V Message Queues are one of the three classic System V IPC mechanisms (along with Shared Memory and Semaphores). They let unrelated processes send and receive typed messages through a kernel-maintained queue — without needing a shared file or a network socket.
In this chapter you will learn how queues are created, how messages are sent and received, how to control queue properties, and why modern code prefers POSIX alternatives. Every concept is explained with working C code.
Chapter Files
What are System V Message Queues? How do they differ from pipes, FIFOs, and POSIX queues? Core concepts explained from scratch.
How to create a new queue or attach to an existing one using msgget(). IPC keys, flags, permissions, and error handling.
How to write messages into a queue and read them back. Message structure, blocking behavior, type-based retrieval, and flags.
How to inspect, modify, and delete message queues using msgctl(). The msqid_ds structure and what information it holds.
A full working example of a server and client communicating using message queues. Includes the request/response pattern.
Understanding the kernel-imposed limits, persistence issues, and why POSIX message queues or sockets are preferred in new code.
Ready to Master Linux IPC?
Start from the intro or jump directly to any section. Each file has working code examples and interview questions.
