NEOCODE

Inter-Process Communication MCQs

IPC BASICS

1. IPC enables:

Correct Answer: a) Process communication

Explanation:
Inter-Process Communication (IPC) refers to mechanisms that allow processes to exchange data and synchronize their actions.

PIPES

2. Pipes are:

Correct Answer: b) Unidirectional

Explanation:
Traditional pipes allow data flow in one direction only (from writer to reader), though some systems support bidirectional pipes.

3. Named pipes (FIFOs) allow:

Correct Answer: a) Unrelated process communication

Explanation:
Unlike unnamed pipes that only work between related processes, named pipes (FIFOs) exist in the filesystem and allow communication between unrelated processes.

4. The popen() function is used to:

Correct Answer: a) Open a pipe to a process

Explanation:
popen() creates a pipe and forks a process, returning a file stream that can be used for reading or writing to the process.

MESSAGE QUEUES

5. Message queues:

Correct Answer: b) Exchange messages

Explanation:
Message queues allow processes to exchange data in the form of messages that are stored in a queue until retrieved by the receiving process.

6. Mailboxes are used for:

Correct Answer: b) Asynchronous communication

Explanation:
Mailboxes allow asynchronous message passing where senders and receivers don't need to be active at the same time.

SHARED MEMORY

7. Shared memory is fast because it:

Correct Answer: b) Avoids system calls

Explanation:
Shared memory is the fastest IPC method because once established, processes access shared data directly without kernel intervention or data copying.

8. A disadvantage of shared memory is:

Correct Answer: a) Complexity in synchronization

Explanation:
While fast, shared memory requires explicit synchronization mechanisms (like semaphores) to prevent race conditions, adding complexity.

SEMAPHORES

9. Semaphores synchronize:

Correct Answer: a) Processes

Explanation:
Semaphores are synchronization primitives used to control access to shared resources among multiple processes or threads.

10. Binary semaphores have values:

Correct Answer: a) 0 and 1

Explanation:
Binary semaphores act as mutex locks with only two states (0=locked, 1=unlocked), while counting semaphores can have higher values.

11. A counting semaphore can range from:

Correct Answer: c) 0 to n

Explanation:
Counting semaphores can have non-negative integer values representing available resources, unlike binary semaphores limited to 0/1.

12. The wait() operation on a semaphore:

Correct Answer: b) Decrements the semaphore

Explanation:
wait() (or P operation) decrements the semaphore value, potentially blocking if the value becomes negative, representing resource acquisition.

SIGNALS & SOCKETS

13. Signals are used for:

Correct Answer: b) Notifying processes of events

Explanation:
Signals are software interrupts that notify processes of events (e.g., termination requests, segmentation faults) but aren't suitable for data transfer.

14. Sockets are primarily used for:

Correct Answer: b) Network communication

Explanation:
Sockets provide endpoints for communication between machines over a network, though they can also be used for inter-process communication on the same host.

MESSAGE PASSING

15. In message passing, synchronization is:

Correct Answer: a) Implicit

Explanation:
Message passing inherently synchronizes processes - the sender blocks until the message is received, and the receiver blocks until a message arrives.

16. Named pipes (FIFOs) differ from unnamed pipes in that they:

Correct Answer: b) Persist beyond process life

Explanation:
Named pipes exist as special files in the filesystem and persist until explicitly deleted, unlike unnamed pipes that disappear when the creating process terminates.