CS 321 Spring 2013 > Lecture Notes for Wednesday, February 13, 2013 |
Two kinds of message-passing IPC: synchronous, or blocking vs. asynchronous, or non-blocking.
Virtual-file-based IPC mechanism. A traditional part of C library under *ix OSs. Synchronous by default. A pipe joins two virtual files: one for input and the other for output. What is written to the second can be read from the first.
Must include <unistd.h>
.
System call pipe
takes a pointer to an array of two int
s.
Returns zero on success.
If successful, array items are open file descriptors,
first open for reading, second for writing.
Use read
system call on first,
write
system call on second.
Both must be closed, by passing them to
the close
system call
(also in <unistd.h>
).
See
pipe1.cpp
(NetRun link)
for a program that does IPC using a pipe.
Message-Passing IPC will be continued next time.
ggchappell@alaska.edu