Inter-Process Communication Pipes Moti Geva geva.biu@gmail.com Operating Systems Inter-Process Communication Pipes Moti Geva geva.biu@gmail.com
Inter-Process Communiacation (IPC) IPCs are mechanisms used to communicate between processes There are various kinds of IPC Files Pipes Signals System V IPC Shared memory Semaphore Message queues Sockets
(Anonymous) Pipes A kernel memory buffer No I/O involved. Limited capacity. Blocks on Read: Empty pipe. Write: Full pipe. Unidirectional data channel. One fd for reading and one for writing.
pipe() system call NAME pipe - create pipe SYNOPSIS #include <unistd.h> int pipe(int pipefd[2]); DESCRIPTION pipefd[0] refers to the read end of the pipe and pipefd[1] refers to the write end of the pipe. RETURN VALUE On success, zero is returned. On error, -1 is returned, and errno is set appropriately. Example: pipe.c
Named pipe (FIFO) When not father-child related Accessed using the filesystem i.e. a special file Creation: mkfifo <fifoname> In C use mkfifo() - C-Library function mknod() system call.