16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Processes II<br />

- Pipe in a single process, immediately after fork<br />

parent process fork child process<br />

read fd<br />

write fd<br />

read fd<br />

write fd<br />

kernel<br />

pipe<br />

->flow of data-><br />

- Pipe between three processes<br />

parent process<br />

write fd<br />

child process<br />

read fd<br />

kernel<br />

pipe<br />

who | sort | lpr<br />

->flow of data-><br />

- Pipe between three processes in a shell pipeline<br />

who process sort process lpr process<br />

read fd read fd<br />

write fd write fd<br />

kernel<br />

pipe 1 pipe 2<br />

->flow of data-><br />

->flow of data-><br />

- Two pipes to provide a bi-directional<br />

flow of data<br />

- create pipe I, create pipe 2<br />

- fork<br />

- parent closes read end of pipe 1<br />

- parent closes write end of pipe 2<br />

- child closes write end of pipe 1<br />

- child closes read end of pipe 2<br />

parent process<br />

read fd<br />

write fd<br />

kernel<br />

pipe 1<br />

child process<br />

read fd<br />

write fd<br />

->flow of data-><br />

pipe 2<br />

->flow of data-><br />

134

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!