A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Message Queues and Message Passing IPC

College Depth 107 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
414prerequisites beneath it
See this on the map →
Inter-Process Communication (IPC)Message Passing IPC: Semantics and Guarantees+1 more→→Pipes and Named Pipes (FIFOs) for IPC
ipc message-queues asynchronous

Core Idea

Message queues enable asynchronous communication where processes send discrete messages that queue in the kernel until the receiver retrieves them. The kernel manages the queue, decoupling sender and receiver in time and making the system more resilient to transient overload. Message queues can enforce FIFO ordering, priority-based delivery, or type-based message selection.

Explainer

From your study of IPC mechanisms, you know that processes can communicate through pipes and shared memory. Pipes work well for streaming byte data between a producer and consumer, but they have limitations: they carry unstructured byte streams, they are typically unidirectional, and the producer blocks when the buffer fills. Message queues address these limitations by providing structured, asynchronous, and potentially prioritized communication between processes.

Think of a message queue as a mailbox managed by the kernel. A sending process drops a discrete message — a self-contained unit with a type tag and a body — into the queue, and continues executing immediately without waiting for the receiver to pick it up. The receiver retrieves messages at its own pace, potentially selecting by type. This temporal decoupling is the key advantage: the sender and receiver do not need to be running at the same time or processing at the same rate. If the receiver is temporarily slow or busy, messages accumulate in the queue rather than blocking the sender (up to a configurable limit).

In the POSIX and System V IPC APIs, message queues live in the kernel and are identified by a key or name. Each message has a type field (a long integer) that the receiver can use to selectively retrieve messages — for example, a server process might use different type values for different client requests, allowing it to process urgent requests before routine ones. This is fundamentally different from pipes, where data is an undifferentiated byte stream and you must read bytes in strict FIFO order. The type-based selection makes message queues suitable for patterns where multiple logical channels share a single queue.

The tradeoff is overhead and complexity. Every send and receive involves a system call and data copying through the kernel, making message queues slower than shared memory for high-throughput scenarios. Queue size limits mean the sender eventually blocks or gets an error if the receiver falls too far behind. And the kernel resources consumed by the queue persist until explicitly removed, unlike pipes which clean up automatically when both ends close. For these reasons, message queues are best suited to scenarios with moderate message rates where the structured, asynchronous, priority-capable communication model justifies the overhead — such as task dispatching, event notification, or request-response protocols between loosely coupled services.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Kernel Architecture and OS Structure → System Calls and User/Kernel Mode → Processes and the Process Control Block → Process Creation: fork() and exec() → Process Termination and Resource Cleanup → Process States and State Transitions → Process Model Formalization → Context Switching and CPU Dispatch → CPU Scheduling Fundamentals → Round-Robin (RR) Scheduling → First-Come-First-Served (FCFS) Scheduling → Scheduling Fairness and Starvation Prevention → Thread Scheduling and Coordination → Semaphores → Monitors and Condition Variables → Message Passing IPC: Semantics and Guarantees → Message Queues and Message Passing IPC

Longest path: 108 steps · 414 total prerequisite topics

Prerequisites (3)

Leads To (1)