






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Slides by Tanenbaum, Modern Operating Systems 3e, slightly modified by M. Damian
different machines
same machine
Processes on the same machine One process spawns the other Used mostly for a pipeline of filters
Processes on any machines Processes created independently Used for client/server communication (e.g., Web)
Parent creates a pipe, then forks a child
Child inherits the file descriptor table (and so the pipe)
Pipe is used between parent and child in one direction
Parent fd[0] fd[1]
pipe OS
Child fd[0] fd[1]
0 read 1 write 2 write 3 4 ...
Parent process file descriptor table
Fork duplicates the descriptor table Open/close/pipe etc. modify the table
Child process file descriptor table read 0 write 1 write 2 3 4 ...
write
pipe buffer amount held room left
fork
pipe
write read 4
data blocks data blocks data blocks ...
open
child
parent
dup2(fd, fd2);
File descriptor data
Process file descriptor table before ... and after dup2(fd, fd2)
File descriptor data
0 1 ...^2 fd2 null
fd
0 1 ...^2 fd
fd
child makes stdin (0) the read side of the pipe
parent makes stdout (1) the write side of the pipe
child process
invokes a new program
Parse command line from stdin Expand wildcards (‘*’) Interpret redirections (‘|’, ‘<‘, and ‘>’) Pipe, fork, dup, exec, and wait, as necessary
And edit till it becomes a UNIX shell
Pipe: create a pipe with a write end and a read end
Open/close: to open or close a file
Dup2: to duplicate a file descriptor