Information Technology Reference
In-Depth Information
Client
Server
(1)
(3)
write
read
write
read
(4)
(2)
User
Kernel
Kernel Buffers
Figure3.10:Interprocess communication between a client process and a server
process.
is room to store the data. Equivalently, if the consumer is faster than the
producer, the buffer will empty and the next read request will stall until the
producer creates more data.
In UNIX, when the producer finishes, it closes its side of the pipe, but
there may still be data queued in the kernel for the consumer. Eventually, the
consumer reads the last of the data, and the read system call will return an \end
of le" marker. Thus, to the consumer, there is no dierence between reading
from a pipe and reading from a file.
Decoupling the execution of the producer and consumer through the use
of kernel buffers reduces the number and cost of context switches. Modern
computers make extensive use of hardware caches to improve performance, but
caches are ineffective if a program only runs for a short period of time before it
must yield the processor to another task. The kernel buffer allows the operating
system to run each process long enough to benefit from reuse, rather than
alternating between the producer and consumer on each system call.
 
Search WWH ::




Custom Search