📝 Interprocess Communication in process implementation (35 MCQs)
Communication Between Independent Process Address Spaces
Interprocess communication (IPC) provides mechanisms through which separate processes exchange information and coordinate their activities. It belongs to process management and supports cooperation between programs that execute within independently protected address spaces. Common IPC mechanisms include shared memory, message passing, pipes, signals, sockets, and synchronisation primitives. Their selection depends on communication patterns, performance requirements, data ownership, and whether processes execute on one computer or across a network.
Why Isolated Processes Require Communication Mechanisms
Process isolation prevents one process from freely accessing another process's private memory, improving protection and execution reliability. However, cooperating processes must exchange information to complete shared tasks. IPC establishes controlled communication channels without removing necessary protection boundaries. It also addresses coordination problems such as concurrent access, message ordering, resource sharing, and synchronisation between independently scheduled execution activities.
IPC Channels, Data Exchange, and Synchronisation
With message passing, processes use send and receive operations through a communication channel managed by the operating system or a communication service. Shared-memory IPC maps a common memory region into multiple address spaces. Synchronisation mechanisms such as semaphores, mutexes, and condition variables coordinate access and prevent conflicting updates to shared information.
Coordinating Two Processes Through an IPC Channel
Consider producer process P generating ten data records for consumer process C. Through a bounded message queue, P sends each record, and C receives them in sequence. If the queue becomes full, P may block until C removes an item. If the queue is empty, C may wait for the next available message.
IPC Performance, Protection, and Synchronisation Requirements
IPC enables modular applications, producer-consumer systems, databases, and cooperating services to share information. Shared memory can provide high throughput because processes access common data directly after setup, but synchronisation remains essential. Message passing offers clearer communication boundaries but may involve copying, system calls, and scheduling overhead. Network-based IPC additionally introduces latency and communication failures.
Misconceptions About IPC and Process Synchronisation
'IPC always requires processes to share memory' is incorrect because message passing uses communication channels. 'Shared memory automatically prevents race conditions' is incorrect because concurrent updates require synchronisation. 'Message passing is limited to separate computers' is incorrect because processes on the same machine can exchange messages through local IPC facilities.
Exam Focus: IPC Mechanisms and Coordination Behaviour
Compare shared memory, message passing, pipes, signals, and sockets by data-transfer method, synchronisation requirements, and communication scope. Trace producer-consumer interactions and identify blocking conditions when buffers are full or empty. Questions may examine race conditions, mutual exclusion, communication overhead, direct versus indirect communication, and the distinction between data exchange and process synchronisation.
Key Terms of Interprocess Communication
- IPC - Communication between separate processes.
- Message passing - Exchanging data through messages.
- Shared memory - Memory region mapped into multiple processes.
- Mutex - Lock providing mutual exclusion.
- Semaphore - Synchronisation variable controlling access.
- Race condition - Result dependent on execution timing.
📝 All Interprocess Communication in process implementation MCQs
Q1. Which interprocess communication model lets cooperating processes exchange data by reading and writing a common region of memory?
📖 Explanation: In shared memory communication, the operating system establishes a region that several processes can map into their address spaces. Data written by one process is immediately visible to the others, so the model avoids copying messages, although it requires explicit synchronisation to prevent conflicts.
Q2. Which interprocess communication model relies on send and receive operations provided by the operating system?
📖 Explanation: Message passing uses send and receive primitives so that the operating system carries messages between processes. Because the kernel mediates each transfer, the model works across machines and avoids shared memory conflicts, but each message typically incurs copying and system call overhead.
Q3. In the context of interprocess communication, what is a bounded buffer?
📖 Explanation: A bounded buffer has a fixed number of slots, so a sender must wait when it is full and a receiver must wait when it is empty. This limit protects system memory and gives a predictable structure for producer and consumer processes that exchange items.
Q4. In direct communication, how are the communicating processes identified?
📖 Explanation: Direct communication requires each process to name the other explicitly, which establishes a link between a specific pair. This makes the relationship clear but limits flexibility, since changing one partner means changing the program that refers to it by name.
Q5. Which buffering arrangement has zero capacity, so that a sender must wait until the receiver is ready to accept the message?
📖 Explanation: A zero-capacity link provides no storage, so the message is passed directly from sender to receiver at the moment both are ready. This is a rendezvous that synchronises the two processes, which contrasts with buffered links where the sender can continue after depositing the message.
Q6. A student believes that shared memory requires no synchronisation because each process simply reads and writes its own data. Which correction is most accurate?
📖 Explanation: Once the region is shared, two processes may update the same location at nearly the same time, producing lost updates or inconsistent values. Mutual exclusion or similar mechanisms must coordinate access. The student's assumption confuses private data with the shared region that defines the model.
Q7. Why is message passing often preferred when processes run on different machines?
📖 Explanation: Processes on separate computers cannot map a common physical memory region, so communication must be carried as messages over the network. Message passing provides exactly this capability and hides the transport details, which is why it is the natural model for distributed communication.
Q8. Why does shared memory generally offer higher communication speed than message passing once it has been set up?
📖 Explanation: After the shared region is established, processes read and write it directly, avoiding the kernel copies and system calls needed for each message. The saving is substantial for frequent or large exchanges, although the synchronisation overhead must still be considered.
Q9. Why does a blocking send with a zero-capacity link synchronise the sender and receiver?
📖 Explanation: With no buffer, the message can only move when both parties are present, so the sender cannot proceed until the receiver accepts it. This rendezvous forces the processes into step with each other, which is useful for coordination but can slow the sender if the receiver is busy.
Q10. Why is buffering helpful in asynchronous communication?
📖 Explanation: When messages are placed in a buffer, the sender does not need to wait for the receiver to be ready. This allows the two processes to run at different speeds, smoothing out bursts of activity. The benefit comes at the cost of storage and of possible blocking when the buffer fills.
Q11. Why can indirect communication through mailboxes simplify a system with many senders and one server?
📖 Explanation: A mailbox decouples senders from receivers. The server listens on one known mailbox, and any client can deposit requests there. Adding or replacing clients therefore does not require changing the server, which is a practical benefit in designs with many clients and a single service.
Q12. Why must a producer-consumer solution using shared memory protect the shared buffer with mutual exclusion?
📖 Explanation: When two processes update the same index or slot concurrently, one update can overwrite another, producing wrong counts or lost items. Mutual exclusion ensures that only one process modifies the critical part at a time, which keeps the buffer consistent under concurrent access.
Q13. Why does an unbounded buffer never block the producer, and why is that not always desirable?
📖 Explanation: An unbounded buffer keeps accepting items, so the producer is never delayed. However, storage is finite in practice, and a persistent mismatch in speed can fill memory, causing failures. The choice between bounded and unbounded buffers is therefore a trade-off between blocking and memory risk.
Q14. Why is choosing between zero, bounded and unbounded buffers described as a trade-off?
📖 Explanation: Each buffer design favours different goals: zero capacity gives tight coordination, bounded buffers provide controlled memory use with possible blocking, and unbounded buffers maximise decoupling. Designers balance synchronisation, memory and responsiveness, so no single choice is universally best.
Q15. Two processes on the same machine must exchange 1 GB of data in many messages. Which mechanism is generally most efficient once established?
📖 Explanation: For large volumes on one machine, shared memory avoids repeated kernel copies, so its per-transfer cost is lower. Message passing still has value for simplicity and isolation, but for heavy data exchange the direct access of shared memory is usually the more efficient choice.
Q16. A bounded buffer has room for 4 items. A producer inserts 6 items rapidly, and no consumer removes anything during that time. How many items can be inserted before the producer blocks?
📖 Explanation: The buffer holds 4 items, so after the fourth insertion the buffer is full and the next insertion must wait. Only 4 items are placed before blocking, even though the producer wishes to send 6. This illustrates how a bounded buffer protects memory but introduces blocking when the consumer is absent.
Q17. A client runs on one machine and a server runs on another machine. Which communication approach is most appropriate?
📖 Explanation: The two machines have separate physical memories, so shared memory cannot connect them directly. Message passing over a network connection carries requests and replies between the client and server, which is the standard approach for distributed client-server communication.
Q18. A bounded buffer has size 3. A producer inserts 5 items in total and a consumer removes 2 items. How many items remain in the buffer at the end?
📖 Explanation: Each insertion adds one item and each removal takes one away, so the net count is items. The buffer capacity limits when insertion must wait, but the final count depends only on total insertions minus removals, which is a useful way to check the state of such systems.
Q19. Processes need to receive requests from any client that sends them, without knowing each client in advance. Which addressing approach best meets this need?
📖 Explanation: A mailbox or port lets any client send to a known address, and the server receives from it without listing every client. This indirection supports open-ended client populations, whereas direct communication would require the server to know and name each sender in advance.
Q20. A message passing system spends 2 ms copying each message, while a shared memory write costs 0.001 ms. For 1000 messages, what is the ratio of message passing time to shared memory time?
📖 Explanation: Message passing takes ms, while shared memory takes ms. The ratio is . The calculation highlights how per-operation costs can differ enormously, which guides the choice of mechanism for heavy communication workloads.
Q21. A student says that shared memory processes never need locks because each process has its own memory. What is the error?
📖 Explanation: The shared region is by definition accessible to multiple processes, so concurrent updates can conflict. Private memory does not remove the need for synchronisation of the shared part. The student mixes private and shared memory and so overlooks the race conditions that locks are designed to prevent.
Q22. A student says that message passing is always slower than shared memory, so it should never be used. Which evaluation is most accurate?
📖 Explanation: Message passing typically has higher overhead per message, but it simplifies coordination, provides isolation and extends naturally to distributed systems. Choosing it can be the right decision even though it is slower for heavy local traffic, so the student's universal claim ignores these advantages.
Q23. A student says that a blocking send over a zero-capacity link returns immediately after placing the message in a buffer, even if the receiver is absent. What is the flaw?
📖 Explanation: The defining property of a zero-capacity link is that no message is stored in between, so the sender remains blocked until the transfer occurs. Claiming the sender returns immediately contradicts the meaning of zero capacity and misunderstands the synchronisation that this design imposes.
Q24. A student says that a mailbox can have only one sender and one receiver at a time. What is the correction?
📖 Explanation: A mailbox is an indirect channel that can be shared among several processes, allowing many senders to deposit messages and many receivers to take them. The student confuses mailboxes with direct one-to-one links, which is a common misunderstanding of indirect communication.
Q25. A student says that an unbounded buffer guarantees the producer can never run out of memory. What is wrong with this claim?
📖 Explanation: An unbounded buffer does not block the producer, but it is still limited by the physical memory available. A sustained imbalance in speed can fill memory and cause failure, so the student confuses the absence of an explicit limit with the absence of any practical limit.
Q26. A graph plots transfer time against message size for two methods. Message passing rises linearly with a large per-message constant, while shared memory stays nearly flat. What is the best inference?
📖 Explanation: The steeper and higher line for message passing shows substantial per-message overhead, whereas the flat shared memory line indicates little dependence on message size once the region exists. The graph therefore supports the inference that message passing is costlier for frequent transfers.
Q27. A graph shows the number of items in a bounded buffer of capacity 5 over time. The count reaches 5 and remains there for a long interval while the producer waits. What does this suggest?
📖 Explanation: A count fixed at capacity means the buffer is full and the producer must wait for space. The consumer is therefore removing items more slowly than they arrive during that period. Reading the plateau at the capacity value correctly identifies the blocking condition and the speed mismatch behind it.
Q28. A timeline shows a sender blocked from time 2 ms until time 6 ms, when the receiver finally calls receive. Which communication design is most consistent with this behaviour?
📖 Explanation: The sender waits until the receiver takes the message, which matches a blocking synchronous send over a zero-capacity link. A non-blocking send or unbounded mailbox would let the sender continue immediately. The timeline's blocked interval is the key evidence for the synchronous design.
Q29. A table lists throughput in messages per second against buffer size: size 1 gives 100, size 4 gives 380, size 8 gives 600, size 16 gives 610, size 32 gives 612. Which conclusion is best supported?
📖 Explanation: Throughput climbs substantially up to size 8 and then changes very little between 16 and 32. The data supports diminishing returns from larger buffers, which is useful when choosing a buffer size that balances memory use against performance.
Q30. Which combination describes indirect, asynchronous, bounded-buffer communication?
📖 Explanation: Indirect communication uses a mailbox, asynchronous sending does not force the sender to wait, and a finite queue gives bounded storage. The other options combine properties that contradict one another, such as zero capacity with permanent storage, so only the first describes the requested behaviour.
Q31. Which pairing correctly matches a shared-memory concept with its purpose?
📖 Explanation: A semaphore is a synchronisation tool used to coordinate access to shared data, which makes it suitable for shared-memory communication. The other pairings assign unrelated functions to these concepts, such as printing or deleting identifiers, so they do not describe the intended relationships.
Q32. A blocking receive is issued on a channel where no message has arrived. Which behaviour is correct?
📖 Explanation: A blocking receive suspends the receiver until data arrives, which synchronises it with the sender's activity. Returning an empty message or terminating the process would be incorrect, since the defining feature of the blocking operation is that the caller waits for the event.
Q33. A producer creates items at 3 items per second and a consumer removes them at 2 items per second. The bounded buffer starts empty and has capacity 10. After how many seconds does the buffer become full?
📖 Explanation: The buffer gains a net of item per second. To reach capacity 10 from empty, it needs seconds. This net-rate reasoning is the key step in producer-consumer analysis, and it ignores the brief startup effects that do not change the steady accumulation.
Q34. A pipeline has four processes, each passing a message to the next through a zero-capacity link, and each hop requires 3 ms for the rendezvous. How long does a message take to travel from the first process to the last?
📖 Explanation: Four processes form three links between consecutive pairs, so the message makes three hops. Each hop takes 3 ms, giving ms in total. Counting links rather than processes is the step that avoids the common error of multiplying by four.
Q35. A web service places incoming requests into a mailbox with room for 50 requests. Requests arrive at 12 per second and are processed at 10 per second. Starting empty, how many seconds pass before the mailbox becomes full?
📖 Explanation: The mailbox gains requests per second. To fill 50 slots from empty it needs seconds. The system designer can use this net-rate calculation to decide whether to add processing capacity before the backlog causes rejected or delayed requests.