Which statement best describes the behavior of a pipe used for inter-process communication?
Think about how data flows between processes using pipes and the order in which data is received.
Pipes create a one-way communication channel where data flows in a first-in, first-out (FIFO) manner from the writing process to the reading process. They do not share memory space and do not store data permanently.
Which of the following is true about shared memory as a method of inter-process communication?
Consider how processes access data in shared memory and what is needed to prevent errors.
Shared memory lets processes access the same memory area directly, which is fast but requires synchronization like locks or semaphores to prevent data corruption.
Consider two processes communicating via a pipe. Process A writes 100 bytes, then Process B reads 50 bytes, then Process A writes another 30 bytes. What is the total number of bytes available for Process B to read after these operations?
Remember that reading from a pipe removes data from the buffer.
Process A writes 100 bytes, Process B reads 50 bytes (removing them), so 50 bytes remain. Then Process A writes 30 more bytes, totaling 80 bytes available for reading.
Which of the following correctly compares pipes and shared memory for inter-process communication?
Think about how synchronization is managed in each IPC method.
Shared memory allows direct access to memory and needs explicit synchronization by the programmer. Pipes internally manage synchronization by blocking reads and writes as needed.
Two processes use a pipe for communication. Process A writes data and waits for a response from Process B. Process B waits to read data before sending a response. Both processes are now stuck waiting indefinitely. What is the most likely cause of this deadlock?
Consider what happens when two processes wait on each other to proceed.
Both processes are waiting for the other to act first, creating a circular wait where neither can proceed, causing a deadlock.