Three producer processes on Linux write 6,000-byte records to the same pipe, one record per blocking write() call. The pipe capacity is 65,536 bytes and PIPE_BUF is 4,096 bytes. A consumer reads 6,000 bytes at a time. Which statement correctly describes what the consumer can receive?
A 6,000-byte read can contain bytes from two producers, because writes above PIPE_BUF are not guaranteed to be atomic.
Each write() call fails with an error, because the kernel rejects any single pipe write larger than PIPE_BUF bytes.
Every read returns one intact record, because the kernel splits each write into 4,096-byte and 1,904-byte pieces that stay adjacent.
Every read returns one intact record, because each 6,000-byte write fits easily within the 65,536-byte pipe buffer.
Unlock full course notes by signing up
Kernel copy time for a pipe transfer
A camera process sends a 750 MB video segment to a transcoder process through an anonymous pipe, using ordinary write() and read() calls. The memory-copy bandwidth is 12 GB/s, with 1 MB = 106 bytes and 1 GB = 109 bytes. Assume each byte is copied into and out of the kernel. Ignoring system-call overhead, how long does the kernel spend copying this data? Give your answer in milliseconds, to the nearest millisecond.
Tracing prioritized message delivery
A POSIX message queue has mq_msgsize = 128 bytes. The following four sends succeed in the listed sequence before a receiver starts. No additional messages arrive. The graph supplies each message's priority.
The receiver makes four successful mq_receive() calls using 256-byte buffers. All other arguments are valid. Complete the table with each returned message name and the number of bytes returned. The final row asks for the smallest receive-buffer size permitted by this queue's configuration, even when the next message is shorter. Enter byte counts as exact integers.
Effect of chunk size on pipe system-call overhead
A single producer sends 512 MiB to a consumer through a pipe. The producer writes, and the consumer reads, in equal fixed-size chunks, and every call transfers one full chunk. Each system call costs 1.5 µs. Counting every write() and every read() call, find the total number of system calls with 4 KiB chunks, the total number with 64 KiB chunks, and the system-call time saved by switching to 64 KiB chunks, in milliseconds to one decimal place.