Ordinary Pipe in Operating System
The Ordinary pipe in Operating Systems allows the two procedures to communicate in a standard way: the procedure writes on the one end (the write end) and reads on the consumer side or another end (the read-end). As a result, ordinary pipes are unidirectional, allowing only one-way communication as shown in a figure.
Ordinary Pipe Uni-directional |
So, here is a problem for us. If we want to communicate with both sides at a time, then what to do? The solution is here:
"if two-way communication is required, two pipes must be used, with each pipe sending data in the different directions" Abraham Silberschatz. See blow fig. to understand better.
We next illustrate constructing ordinary pipes on both UNIX and Windows systems. In both examples, one process writes the message Greeting to the pipe while the other process read the message on the other side of the pipe. In UNIX systems, ordinary pipes are constructed using the function
This function creates the pipe that is accessed the int fb[] file descriptor: fd[0] is the read-end of the pipe and fd[1] is the write-end. UNIX treat a pipe as special type of file. Thus pipe can be accessed using ordinary read(), write() system calls.
Ordinary pipes on Windows systems are termed anonymous pipes, and they behave similarly to the UNIX systems in functionality (they are unidirectional). In addition, reading and writing to the pipe can be accomplished by the following two simple functions;
In Windows, the pipe is creating using CreatePipe() function. Note that ordinary pipes require a parent-child relationship between computing processes in both UNIX and Windows systems. This means that pipes can be used only for communication between processes on the same machine.
"if two-way communication is required, two pipes must be used, with each pipe sending data in the different directions" Abraham Silberschatz. See blow fig. to understand better.
Ordinary Pipe Bi-directional |
In UNIX Systems
We next illustrate constructing ordinary pipes on both UNIX and Windows systems. In both examples, one process writes the message Greeting to the pipe while the other process read the message on the other side of the pipe. In UNIX systems, ordinary pipes are constructed using the function
pipe(int fd[])
|
This function creates the pipe that is accessed the int fb[] file descriptor: fd[0] is the read-end of the pipe and fd[1] is the write-end. UNIX treat a pipe as special type of file. Thus pipe can be accessed using ordinary read(), write() system calls.
In Windows Systems
Ordinary pipes on Windows systems are termed anonymous pipes, and they behave similarly to the UNIX systems in functionality (they are unidirectional). In addition, reading and writing to the pipe can be accomplished by the following two simple functions;
ReadFile()
WrireFile()
|
In Windows, the pipe is creating using CreatePipe() function. Note that ordinary pipes require a parent-child relationship between computing processes in both UNIX and Windows systems. This means that pipes can be used only for communication between processes on the same machine.
Some characteristic of Ordinary Pipes
- An ordinary pipe cannot be accessed from outside the process that created it.
- A parent process creates a pipe and uses its communicate with a child process that is created via fork().
- A Pipe is a special type of file, the child inherits the pipe from its parent process.
- The Ordinary pipe is unidirectional (one-way communication between processes). Two-way communication is allowed in Named Pipe
Sign up here with your email
ConversionConversion EmoticonEmoticon