Inter-Process Communication – Operating System
Q1.
Inter-process communication (IPC) allows processes to:
A) Share only CPU time
B) Communicate and synchronize their actions
C) Execute concurrently without data sharing
D) Access each other’s code directly
Answer: B
Solution:
IPC enables communication and synchronization between independent processes — essential for cooperating processes.
Q2.
Which of the following is not a valid IPC mechanism?
A) Message passing
B) Shared memory
C) Semaphores
D) Interrupt vector
Answer: D
Solution:
Interrupt vector is a hardware-level structure, not used for process-to-process communication.
Q3.
In message passing, processes communicate via:
A) Kernel buffers
B) Shared global variables
C) Files on disk
D) Network sockets only
Answer: A
Solution:
Message passing typically uses kernel buffers for temporary message storage.
Q4.
Which IPC mechanism requires explicit synchronization using semaphores or monitors?
A) Message passing
B) Shared memory
C) Signal handling
D) Mailboxes
Answer: B
Solution:
In shared memory, synchronization must be explicitly handled by the programmer.
Q5.
In a distributed system, message passing is preferred over shared memory because:
A) Shared memory is faster
B) Memory cannot be physically shared
C) Messages are always reliable
D) Context switching is not required
Answer: B
Solution:
Processes in distributed systems reside on different machines, so shared memory is impossible.
Q6.
In UNIX, the system call used to create a pipe is:
A) pipe()
B) mkfifo()
C) socket()
D) open()
Answer: A
Solution:pipe() creates a unidirectional communication channel between related processes.
Q7.
A pipe allows:
A) Bidirectional communication
B) Unidirectional communication
C) Communication between unrelated processes only
D) Access to shared memory
Answer: B
Solution:
A standard pipe supports unidirectional data flow — one end writes, the other reads.
Q8.
To achieve bidirectional communication between two processes using pipes, we need:
A) One pipe
B) Two pipes
C) A shared file
D) Message queue
Answer: B
Solution:
Pipes are unidirectional, so two pipes are needed — one for each direction.
Q9.
A message queue differs from a pipe because:
A) It allows random access
B) It is not maintained by the kernel
C) It allows communication between unrelated processes
D) It cannot handle variable-sized messages
Answer: C
Solution:
Unlike pipes, message queues can be accessed by unrelated processes via keys.
Q10.
Which of the following IPC mechanisms provides full-duplex communication?
A) Ordinary pipes
B) FIFOs
C) Sockets
D) Shared memory
Answer: C
Solution:
Sockets support full-duplex communication — both ends can send/receive simultaneously.
Q11.
What is the maximum number of processes that can communicate through one pipe?
A) 2
B) Unlimited
C) 1
D) Depends on file descriptor limits
Answer: A
Solution:
A pipe connects exactly two processes — one writer, one reader.
Q12.
In shared memory, which component maps memory into a process’s address space?
A) Scheduler
B) Kernel
C) Compiler
D) MMU
Answer: B
Solution:
Kernel maps shared memory regions into user space for IPC access.
Q13.
Which system call is used to attach shared memory in UNIX?
A) shmget()
B) shmat()
C) shmctl()
D) shmdt()
Answer: B
Solution:shmat() attaches a shared memory segment to a process’s address space.
Q14.
In message passing, synchronization can be:
A) Only blocking
B) Only non-blocking
C) Either blocking or non-blocking
D) None
Answer: C
Solution:
Messages may be blocking (synchronous) or non-blocking (asynchronous) depending on design.
Q15.
Blocking send means:
A) Sender continues immediately
B) Sender waits until receiver acknowledges
C) Receiver blocks until message arrives
D) Both sender and receiver block
Answer: B
Solution:
In blocking send, the sender waits until the message is received or buffered.
Q16.
If a process sends data to a mailbox not yet created, it results in:
A) Deadlock
B) Error/Failure
C) Race condition
D) Message queued automatically
Answer: B
Solution:
Sending to an invalid mailbox causes an error, since there’s no recipient object.
Q17.
Which IPC mechanism provides the fastest communication speed?
A) Message passing
B) Shared memory
C) Sockets
D) Signals
Answer: B
Solution:
Shared memory avoids kernel intervention after setup, making it fastest for IPC.
Q18.
Signals in UNIX are used for:
A) Sending small notifications between processes
B) Transferring large data
C) Synchronizing shared memory access
D) Process creation
Answer: A
Solution:
Signals are lightweight IPC methods to notify or interrupt a process.
Q19.
Which IPC method can be used between unrelated processes?
A) Ordinary pipe
B) Named pipe (FIFO)
C) Shared local variables
D) Threads
Answer: B
Solution:
Named pipes (FIFOs) can be opened by unrelated processes using a pathname.
Q20.
In a system with 3 processes using message passing, each sends 5 messages of 100 bytes. What is total traffic handled by the kernel?
A) 1.5 KB
B) 3 KB
C) 4.5 KB
D) 6 KB
Answer: C
Solution:
3 × 5 × 100 = 1500 bytes sent; also 1500 received → 3,000 bytes = 3 KB, but if each copy counts twice (kernel buffer + receiver), total = 4.5 KB.
Q21.
Which of the following is not a characteristic of message passing?
A) Data copied through kernel
B) Implicit synchronization
C) Faster than shared memory
D) Communication through system calls
Answer: C
Solution:
Message passing is slower than shared memory because data must pass via kernel.
Q22.
Shared memory IPC model is typically used for:
A) Small control messages
B) Bulk data transfer
C) Interrupts
D) Hardware signaling
Answer: B
Solution:
Shared memory is ideal for large-volume data sharing among processes.
Q23.
Which of the following IPC mechanisms uses key–value identifiers?
A) Shared memory
B) Message queue
C) Signals
D) Sockets
Answer: B
Solution:
Message queues in UNIX use unique keys for identification.
Q24.
Which IPC mechanism can communicate between processes on different systems?
A) Shared memory
B) Message queues
C) Sockets
D) Pipes
Answer: C
Solution:
Sockets enable networked IPC — connecting processes across systems.
Q25.
In UNIX, ftok() is used to:
A) Create a unique key for IPC objects
B) Attach shared memory
C) Send a signal
D) Create a socket
Answer: A
Solution:ftok() converts a pathname and project ID into a unique key for IPC resources.
Inter-Process Communication (IPC)
Q26.
When two processes communicate via shared memory, data consistency must be ensured using:
A) File descriptors
B) Synchronization mechanisms like semaphores
C) Pipes
D) Interrupts
Answer: B
Solution:
Shared memory does not provide automatic synchronization — semaphores or monitors must be used to prevent race conditions.
Q27.
In message passing, if the sender does not wait for an acknowledgment, it is called:
A) Synchronous communication
B) Asynchronous communication
C) Blocking communication
D) Sequential communication
Answer: B
Solution:
When the sender continues without waiting, it’s asynchronous (non-blocking) communication.
Q28.
A message queue uses which data structure internally?
A) Stack
B) Linked list
C) Array
D) Circular buffer
Answer: D
Solution:
Most message queues implement circular buffers for efficient enqueue/dequeue of messages.
Q29.
Which IPC mechanism can signal a specific event occurrence to another process?
A) Shared memory
B) Signal
C) Message queue
D) Socket
Answer: B
Solution:
Signals are used to asynchronously notify a process about events (e.g., SIGINT, SIGKILL).
Q30.
A process sends a message and waits for a reply. This is an example of:
A) Asynchronous communication
B) Synchronous communication
C) Buffered communication
D) Non-blocking communication
Answer: B
Solution:
If sender waits for acknowledgment, communication is synchronous.
Q31.
Which system call removes a message queue in UNIX?
A) msgctl()
B) msgget()
C) msgsend()
D) msgrcv()
Answer: A
Solution:msgctl() can control and remove message queues using IPC_RMID.
Q32.
A named pipe (FIFO) can be created using:
A) pipe()
B) mkfifo()
C) socket()
D) open()
Answer: B
Solution:mkfifo() creates a FIFO special file in UNIX for named pipes.
Q33.
Which IPC mechanism can easily handle communication across a network?
A) FIFO
B) Message queue
C) Socket
D) Shared memory
Answer: C
Solution:
Sockets are designed for inter-machine communication (TCP/UDP).
Q34.
Which of the following is not an advantage of message passing?
A) Easier synchronization
B) No need for shared memory
C) Faster data transfer
D) Simplicity for distributed systems
Answer: C
Solution:
Message passing is slower than shared memory because it involves system call overhead.
Q35.
Shared memory is generally used when:
A) Processes are on different systems
B) Large data transfer is needed
C) Communication must be encrypted
D) Kernel involvement is required each time
Answer: B
Solution:
Shared memory is ideal for high-volume data sharing with minimal kernel overhead.
Q36.
What is the typical size of a UNIX pipe buffer?
A) 512 bytes
B) 4 KB
C) 64 KB
D) Implementation-dependent
Answer: D
Solution:
Pipe buffer sizes vary by implementation (commonly 4 KB, 64 KB, etc.).
Q37.
Which of these IPC mechanisms can achieve broadcast communication easily?
A) Pipes
B) Message queues
C) Shared memory
D) Signals
Answer: B
Solution:
Message queues can send messages to multiple receivers if designed with broadcast semantics.
Q38.
If two processes write simultaneously to the same shared memory segment:
A) The last write always wins
B) Data corruption may occur
C) Kernel prevents it
D) Writes are serialized automatically
Answer: B
Solution:
Without synchronization, race conditions can corrupt data in shared memory.
Q39.
Which of the following functions in sockets binds a port number to a socket?
A) socket()
B) connect()
C) bind()
D) listen()
Answer: C
Solution:bind() associates a socket with a specific IP and port.
Q40.
When a process receives a SIGKILL signal:
A) It can ignore it
B) It can handle it with a custom handler
C) It terminates immediately
D) It is suspended
Answer: C
Solution:SIGKILL cannot be caught or ignored — process is terminated immediately.
Q41.
What is the main disadvantage of shared memory IPC?
A) High kernel overhead
B) Requires explicit synchronization
C) No support for large data transfer
D) Works only for related processes
Answer: B
Solution:
Shared memory is efficient but synchronization must be handled manually.
Q42.
A message queue with capacity 5 currently has 5 messages. If another message is sent:
A) Message is lost
B) Sender blocks until space is free
C) Receiver terminates
D) Queue expands automatically
Answer: B
Solution:
If queue is full, sender blocks until space becomes available.
Q43.
A mailbox provides:
A) Direct communication between processes
B) Indirect communication using an intermediary
C) Shared memory synchronization
D) Process termination signaling
Answer: B
Solution:
Mailboxes are intermediate message holders for indirect communication.
Q44.
Which of the following statements about signals is true?
A) Signals carry data payloads
B) Signals interrupt processes asynchronously
C) Signals are blocking communication mechanisms
D) Signals are always synchronous
Answer: B
Solution:
Signals asynchronously interrupt processes to notify events.
Q45.
Which IPC mechanism supports both connection-oriented and connectionless modes?
A) Pipes
B) Message queues
C) Sockets
D) Shared memory
Answer: C
Solution:
Sockets support TCP (connection-oriented) and UDP (connectionless) communication.
Q46.
Which synchronization primitive is commonly used with shared memory IPC?
A) Mutex
B) Semaphore
C) Monitor
D) All of the above
Answer: D
Solution:
All three (mutexes, semaphores, monitors) are valid synchronization tools.
Q47.
What happens when a reading process tries to read from an empty pipe?
A) It gets garbage data
B) It blocks until data is available
C) It terminates
D) It reads zero bytes immediately
Answer: B
Solution:
Reader blocks until data is written into the pipe.
Q48.
A socket is identified uniquely by:
A) IP address only
B) Port number only
C) Combination of IP and port
D) Process ID
Answer: C
Solution:
Sockets are uniquely identified by (IP address, port) pair.
Q49.
In UNIX, the system call used to send messages in message queue IPC is:
A) msgctl()
B) msgsnd()
C) msgrcv()
D) mq_open()
Answer: B
Solution:msgsnd() is used to send messages to a message queue.
Q50.
In shared memory IPC, the producer-consumer problem can arise due to:
A) Improper buffer size
B) Lack of synchronization
C) Kernel memory limits
D) Invalid page mapping
Answer: B
Solution:
Without synchronization, producers/consumers can overwrite or read invalid data.
Q51.
Which of the following supports communication between unrelated processes?
A) Anonymous pipes
B) Named pipes (FIFOs)
C) Signals
D) Local variables
Answer: B
Solution:
Named pipes (FIFOs) enable unrelated processes to communicate using filesystem pathnames.
Q52.
Remote Procedure Call (RPC) allows:
A) Processes to call procedures on remote systems
B) Shared memory access
C) Local file I/O
D) Asynchronous messaging
Answer: A
Solution:
RPC allows invoking functions on another system as if they were local.
Q53.
In UNIX IPC, message queues, semaphores, and shared memory are collectively called:
A) POSIX IPC
B) System V IPC
C) Kernel IPC
D) Thread IPC
Answer: B
Solution:
System V IPC includes message queues, semaphores, shared memory APIs.
Q54.
In sockets, listen() is used by:
A) Client process
B) Server process
C) Kernel
D) Any process
Answer: B
Solution:
Server calls listen() to mark the socket as passive and ready to accept connections.
Q55.
Which system call is used by the server to accept incoming connections?
A) bind()
B) listen()
C) accept()
D) connect()
Answer: C
Solution:accept() is called by the server to accept pending client connection requests.
Q56.
In signal handling, the function used to register a handler is:
A) sigset()
B) signal()
C) sigsend()
D) sigraise()
Answer: B
Solution:signal() associates a user-defined handler with a signal type.
Q57.
When a process uses pause() in UNIX, it:
A) Stops CPU execution permanently
B) Waits for any signal
C) Terminates immediately
D) Blocks all other processes
Answer: B
Solution:pause() suspends the process until a signal is received.
Q58.
Which of the following IPC mechanisms provides lowest latency?
A) Shared memory
B) Message queue
C) FIFO
D) Socket
Answer: A
Solution:
Shared memory avoids kernel copying, giving the lowest latency.
Q59.
Which of the following is true about semaphores?
A) They transfer data between processes
B) They are used for synchronization, not communication
C) They can hold messages
D) They work only within a process
Answer: B
Solution:
Semaphores only synchronize access — they do not transfer actual data.
Q60.
How does the kernel identify a specific IPC object?
A) File descriptor
B) Process ID
C) IPC key and ID
D) Virtual address
Answer: C
Solution:
Each IPC object has a key and system-generated ID.
Q61.
If a process detaches from a shared memory segment using shmdt():
A) Segment is destroyed immediately
B) Only that process loses access
C) All processes lose access
D) Data is deleted
Answer: B
Solution:shmdt() detaches the calling process from the shared segment.
Q62.
Which of the following IPC mechanisms works both locally and remotely?
A) Pipes
B) Sockets
C) Message queues
D) Shared memory
Answer: B
Solution:
Sockets support both local and network communication.
Q63.
What happens if a process writes to a pipe with no reader?
A) Data stored indefinitely
B) Write fails with SIGPIPE
C) Kernel buffers it forever
D) Process blocks
Answer: B
Solution:
If no reader exists, a SIGPIPE signal is sent and write fails.
Q64.
When two processes communicate using message passing and the message queue is full, a blocking send will:
A) Drop the message
B) Wait until space is available
C) Terminate the process
D) Overwrite the oldest message
Answer: B
Solution:
In a blocking send, the sender waits until there is space in the message queue before proceeding.
Q65.
Which IPC mechanism is best suited when processes require low-latency, high-volume data sharing?
A) Message queues
B) Shared memory
C) Signals
D) Pipes
Answer: B
Solution:
Shared memory allows direct memory access with minimal kernel involvement — fastest for large data.
Q66.
Which IPC method introduces the most context switches?
A) Shared memory
B) Message passing
C) Semaphores
D) Signals
Answer: B
Solution:
Each message send and receive involves system calls, hence more context switches than shared memory.
Q67.
In UNIX System V IPC, msgsnd() and msgrcv() are used for:
A) Pipes
B) Message queues
C) Shared memory
D) Semaphores
Answer: B
Solution:msgsnd() and msgrcv() are message queue functions to send and receive messages.
Q68.
In POSIX message queues, messages are retrieved in which order by default?
A) FIFO
B) Priority-based
C) LIFO
D) Random
Answer: B
Solution:
POSIX message queues are priority-based, unlike System V which is FIFO by default.
Q69.
Which function removes a shared memory segment from the system?
A) shmdt()
B) shmget()
C) shmctl()
D) ftok()
Answer: C
Solution:shmctl() with IPC_RMID command removes a shared memory segment.
Q70.
In a producer–consumer setup using shared memory, synchronization must be achieved using:
A) Interrupts
B) Semaphores
C) Pipes
D) None
Answer: B
Solution:
Semaphores prevent race conditions when producer and consumer access shared memory concurrently.
Q71.
If multiple processes read the same shared memory simultaneously without writing, it leads to:
A) Deadlock
B) Starvation
C) No issue
D) Race condition
Answer: C
Solution:
Concurrent read-only access is safe; synchronization is needed only for writes.
Q72.
A socket bound to port 0 indicates:
A) Error condition
B) Random port assigned by OS
C) Kernel reserved port
D) Invalid socket
Answer: B
Solution:
Binding a socket to port 0 requests the OS to assign a free port automatically.
Q73.
Which of the following mechanisms is used for remote IPC?
A) RPC
B) Signals
C) Named pipes
D) Message queues
Answer: A
Solution:
Remote Procedure Call (RPC) allows processes on different systems to communicate.
Q74.
Which is the main disadvantage of shared memory IPC?
A) High latency
B) Kernel overhead
C) Complexity of synchronization
D) Limited data size
Answer: C
Solution:
Shared memory requires manual synchronization (via semaphores/monitors), which increases complexity.
Q75.
In message passing, a non-blocking receive returns:
A) Immediately, possibly with no message
B) Only after receiving a message
C) When the sender acknowledges
D) Only if the queue is full
Answer: A
Solution:
A non-blocking receive call returns immediately, even if no message is available.
Q76.
Which IPC mechanism is ideal for client-server applications communicating over a network?
A) Signals
B) Pipes
C) Sockets
D) Shared memory
Answer: C
Solution:
Sockets enable communication between distributed systems (client-server model).
Q77.
In System V message queues, maximum message size is controlled by:
A) msgctl()
B) Kernel parameter msgmax
C) shmget()
D) ftok()
Answer: B
Solution:msgmax defines the maximum message size the kernel allows.
Q78.
In shared memory, when a process terminates abnormally without detaching, the memory:
A) Is automatically released
B) Remains allocated
C) Is locked
D) Becomes read-only
Answer: B
Solution:
Shared memory remains until explicitly removed using shmctl(IPC_RMID).
Q79.
The system call used to create a semaphore set in UNIX is:
A) semget()
B) semctl()
C) semop()
D) shmget()
Answer: A
Solution:semget() creates a new semaphore set or accesses an existing one.
Q80.
When two processes continuously send blocking messages to each other without reading, it results in:
A) Race condition
B) Deadlock
C) Starvation
D) Mutual exclusion
Answer: B
Solution:
Both processes wait indefinitely for each other — a deadlock.
Q81.
Which of the following best describes a pipe?
A) Circular buffer managed by kernel
B) Shared memory region
C) Synchronization variable
D) User-space array
Answer: A
Solution:
A pipe is a kernel-managed circular buffer for sequential communication.
Q82.
The main purpose of select() system call in socket IPC is:
A) Close connection
B) Monitor multiple sockets for I/O
C) Create sockets
D) Send messages
Answer: B
Solution:select() allows monitoring of multiple sockets for reading/writing readiness.
Q83.
Which IPC mechanism uses file descriptors in UNIX?
A) Shared memory
B) Pipes
C) Semaphores
D) Message queues
Answer: B
Solution:
Pipes and sockets are represented by file descriptors for read/write operations.
Q84.
If two processes communicate using shared memory of 1 MB and both write simultaneously, it can lead to:
A) Data consistency issues
B) Deadlock
C) Starvation
D) Context switch
Answer: A
Solution:
Simultaneous writes without synchronization cause data inconsistency.
Q85.
Which function detaches a shared memory segment from a process?
A) shmdt()
B) shmctl()
C) shmget()
D) semop()
Answer: A
Solution:shmdt() detaches the shared segment from a process’s address space.
Q86.
Which IPC primitive allows one process to wait for a specific signal from another?
A) pause()
B) alarm()
C) signal()
D) waitpid()
Answer: A
Solution:pause() suspends the process until a signal is received.
Q87.
In UNIX, named pipes (FIFOs) persist until:
A) System reboot
B) All processes close them
C) Explicitly deleted using unlink()
D) Kernel automatically removes them
Answer: C
Solution:
Named pipes remain as files until unlink() removes them.
Q88.
In an IPC system, message buffering can be:
A) Zero capacity, bounded, or unbounded
B) Bounded only
C) Unbounded only
D) Random
Answer: A
Solution:
Buffer capacity types: zero (no queue), bounded (limited), unbounded (infinite).
Q89.
If buffer capacity is zero, message passing requires:
A) Asynchronous communication
B) Synchronous rendezvous
C) Shared memory
D) Interrupts
Answer: B
Solution:
With zero capacity, sender and receiver must synchronize directly (rendezvous).
Q90.
Which IPC mechanism can achieve synchronization without data transfer?
A) Signals
B) Shared memory
C) Sockets
D) Message queues
Answer: A
Solution:
Signals can synchronize processes by notifying without exchanging data.
Q91.
A socket pair (AF_UNIX, SOCK_STREAM) is used for:
A) Network communication
B) Local full-duplex communication
C) Datagram transfer
D) Half-duplex only
Answer: B
Solution:
UNIX domain sockets of type SOCK_STREAM provide local full-duplex IPC.
Q92.
Which IPC mechanism typically uses a key generated via ftok()?
A) Shared memory, semaphore, or message queue
B) Signals
C) Sockets
D) Files
Answer: A
Solution:
System V IPC objects — shared memory, semaphores, and message queues — use ftok() keys.
Q93.
In a message queue with max 10 messages, if 12 are sent non-blocking:
A) Two are queued
B) Two cause error (EAGAIN)
C) All are accepted
D) Queue expands dynamically
Answer: B
Solution:
Extra messages beyond queue limit cause a non-blocking error EAGAIN.
Q94.
In UNIX, signals with numbers 1–31 are usually:
A) User-defined
B) Real-time
C) Standard system signals
D) Ignored
Answer: C
Solution:
Signal numbers 1–31 correspond to standard system-defined signals.
Q95.
Which IPC facility provides message persistence even after all processes terminate?
A) Message queues
B) Shared memory
C) Pipes
D) Semaphores
Answer: A
Solution:
System V message queues persist until explicitly removed with msgctl().
Q96.
Which of the following IPC techniques can be used across a network?
A) Sockets
B) Pipes
C) Shared memory
D) Signals
Answer: A
Solution:
Sockets enable communication between remote systems.
Q97.
Which mechanism provides both communication and synchronization?
A) Semaphores
B) Message passing
C) Shared memory
D) Signals
Answer: B
Solution:
Message passing inherently supports data exchange and synchronization.
Q98.
The function mq_open() in POSIX is used to:
A) Create or open a message queue
B) Send a message
C) Receive a message
D) Delete shared memory
Answer: A
Solution:mq_open() opens or creates a POSIX message queue descriptor.
Q99.
In a two-process communication system using shared memory, the critical section problem can occur if:
A) Both processes write concurrently
B) Only one reads
C) Memory is read-only
D) Processes are unrelated
Answer: A
Solution:
Concurrent writes to shared memory may cause inconsistent or lost updates — a critical section issue.
Q100.
Which of the following is the most efficient IPC method within the same machine?
A) Message queues
B) Pipes
C) Shared memory
D) Sockets
Answer: C
Solution:
Shared memory allows direct access, minimizing kernel overhead — fastest for local IPC.