Lab 6 Pipe

You might also like

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

Hijjawi Faculty for Engineering Technology Computer Engineering Department System Programming Lab (CPE 466)

Lab 6: Interprocess communication, Pipe

Goals:
Detailed Interprocess communication using pipe.

Background:

Interprocess communication (IPC) refers to the coordination of activates among cooperating processes. A common example of this need is managing access to a given system resource. Pipe is a simple synchronized way of passing information between two processes. A pipe can be viewed as a special file that can store only a limited amount of data and uses a FIFO access scheme to retrieve data. In a logical view of a pipe, data is written to one end and read from the other. The system provides synchronization between the reading and writing process. It also solves the producer/consumer problem: writing to a full pipe automatically blocks, as does reading from an empty pipe. On the other hand ,if no process has a pipe open for writing, a read from an empty pipe returns 0,indicating an end of file condition. #include <unistd.h> int pipe(int fds[2]); This system call is used to create a read-write pipe. The call takes as an argument an array of 2 integers that will be used to save the two file descriptors used to access the pipe. The first is to read from the pipe, and the second is to write to the pipe. If the call to pipe() succeeded, a pipe will be created, pipes[0] will contain the number of its read file descriptor, and pipes[1] will contain the number of its write file descriptor. Practical: Build a small database that has a limited number of records of clients information in a certain bank such as clients ID, password and balance. Then implements the following scenario: Process number one lets the client to enter his ID and password then passes them to process number two that checks if this client exist in the bank database or not , if it exist it will return the index of this client in the database , else it will return -1. According to the return value of process number two , process number one views the clients balance or error message.

GOOD LUCK

You might also like