CS 321 Spring 2013  >  Lecture Notes for Wednesday, February 13, 2013

CS 321 Spring 2013
Lecture Notes for Wednesday, February 13, 2013

Message-Passing IPC

Two kinds of message-passing IPC: synchronous, or blocking vs. asynchronous, or non-blocking.

Pipes

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 ints. 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.


CS 321 Spring 2013: Lecture Notes for Wednesday, February 13, 2013 / Updated: 13 Feb 2013 / Glenn G. Chappell / ggchappell@alaska.edu