Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

PIPES

AND FIFO
Presented by :
Haripriya (22261A3259)
01. WHAT ARE PIPES? 05. EXAMPLE PROGRAM

02. TYPES OF PIPES

03. FEATURES AND LIMITATIONS OF PIPES

04. FEATURES OF FIFO’S


TABLE OF
CONTENTS
WHAT ARE PIPES?
Pipes are a form of communication between
processes that allow the output of one process
to be used as input to another.

Pipes are implemented using a special type of


file descriptor

Pipe is accessed through int fd[] file


description

fd[0] is the read end and fd[1] is the write end


TYPES OF PIPES

There are two types of files :


Unnamed Pipes :
They are created using the pipe system call and exist
within the parent - child process hierarchy.
Named Pipes:
They are also know as FIFOs and are created using
the mkfifo command and have a unique name in the
file system.
FEATURES AND LIMITATIONS OF PIPES
Features :

• Pipes are unidirectional , meaning data flow only in one direction

• Pipes are useful for communication between related processes, such as a parent
process and its child processes.

Limitations :

• They are restricted to communication between processes within the same system.

• Data sent through pipes must follow a specific order due to their FIFO nature.
FEATURES OF FIFOS

• FIFOs are implemented as special files in the file


system

• FIFOs are bidirectional, enabling data flow in both


directions.

• FIFOs are useful for interprocess communication


between different applications or systems
EXAMPLE PROGRAM :
#include <stdio.h> OUTPUT :
#include <unistd.h>
#define MSGSIZE 16 hello, world #1
char* msg1 = "hello, world #1"; hello, world #2
char* msg2 = "hello, world #2"; hello, world #3
char* msg3 = "hello, world #3";
int main()
{
char inbuf[MSGSIZE];
int p[2], i;
if (pipe(p) < 0)
exit(1);
/* continued */
/* write pipe */
write(p[1], msg1, MSGSIZE);
write(p[1], msg2, MSGSIZE);
write(p[1], msg3, MSGSIZE);
for (i = 0; i < 3; i++) {
/* read pipe */
read(p[0], inbuf, MSGSIZE);
printf("% s\n", inbuf);
}
return 0;
}
THANK YOU

You might also like