Week 9 - July 8-12
Introduction
This week we are going to study two more methods of inter-process communication - pipes and fifos.
Videos
Quiz
Lecture Material
Labs
- Lab 6 - server/client communications.
- Lab 7 - pipes between processes.
Assignment(s)
Assignment 1.
Sample Code
Pipes
- A simple pipe can be found in pipe.cpp.
Synchronization with pipes can be seen in pipe2.cpp.
Using an ioctl to see how much unread data remains in a pipe can be seen in pipe3.cpp.
A C/C++ implementation of piping the output of one command to another can be seen in pipeline.c
and pipeline2.c.
The Linux function dup2 is used in this example.
Consider dup2(a,b) to mean make b also connect to what a is connected to.
Images illustrating pipes from the command line and pipes from C/C++ source code can be found at
Pipes1.JPG (for pipeline.c) and
Pipes2.JPG (for pipeline2.c).
Executing a system command from within a C++ program can be seen in pipeout.cpp.
The Makefile for all of these can be found here.
Fifos
- Code demonstrating fifo's can be found in fifo1.cpp and fifo2.cpp. fifo1 prompts the user for keyboard input and sends the buffer to fifo2. fifo2 converts everything to upper case and sends it back to fifo1.
The Makefile can be found here.