Presentation is loading. Please wait.

Presentation is loading. Please wait.

4061 Session 13 (2/27). Today Pipes and FIFOs Today’s Objectives Understand the concept of IPC Understand the purpose of anonymous and named pipes Describe.

Similar presentations


Presentation on theme: "4061 Session 13 (2/27). Today Pipes and FIFOs Today’s Objectives Understand the concept of IPC Understand the purpose of anonymous and named pipes Describe."— Presentation transcript:

1 4061 Session 13 (2/27)

2 Today Pipes and FIFOs

3 Today’s Objectives Understand the concept of IPC Understand the purpose of anonymous and named pipes Describe where file descriptors point after system calls to pipe, fork, and dup Write C code that allows parent and child processes to communicate with pipes or FIFOs –Specifically: write a “filter”

4 Admin Quiz 2: Nice!

5 Inter-Process Communication (IPC) Techniques for the exchange of data between processes or threads

6 Why IPC?

7 UNIX IPC Lots of ways to do it. We’ll talk about some of the classics in 4061. Today: –Pipes and FIFOs Later: –Signals, Sockets

8 Pipes Aka: anonymous pipes or unnamed pipes Very simple IPC Remember bash shell: | –Chain stdout of one process with stdin of another process –E.g.: ps ax | grep java

9 Pipes: Conceptually

10 One-way channel for information –Write to the input end, read from the output end Think of a pipe as a buffer in the operating system that you can read from and write to. –If you fill it up, the writer blocks –If it’s empty, the reader blocks

11 Opening a Pipe A process issues a command to create a pipe, and receives two file descriptors.

12 Forking To communicate with something, fork.

13 Cleaning Up Close unused descriptors.

14 Details What do the file descriptors point to? –Well, files...but a special type (in pipefs). –So we can still use file-oriented calls, such as read, write, close, etc. –No mount point, so not visible with ls If you close one end of a pipe, you can’t reopen it

15 Details Often implemented as a circular buffer

16 Shortcut Methods popen and pclose

17 FIFOs (a.k.a. Named Pipes) (first in first out) File (of type FIFO) in the filesystem. –Access permissions Kernel structures are set up on open Multiple processes can write, only one can read Writes (smaller than the buffer) are atomic


Download ppt "4061 Session 13 (2/27). Today Pipes and FIFOs Today’s Objectives Understand the concept of IPC Understand the purpose of anonymous and named pipes Describe."

Similar presentations


Ads by Google