Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have reposted this questions again please help Linux operating systems with ex

ID: 3775743 • Letter: I

Question

I have reposted this questions again please help Linux operating systems with explanation Lab. Assignment 4 Interprocess Communication Using Pipes. Write well-comment program which implements interprocess communication between a parent and child processes. Your program should implement the following steps: 1. The parent creates an unnamed pipe using pipe O. process 2. The parent process forks (use fork 0) and the reader (parent) closes its write 3. The writer (child) closes its read end of the pipe, end of the pipe. 4. The parent and child communicate by using write and read calls. 5. Each process closes its active pipe descriptor when it's finishes with it. Note: You may use an example in your LINuxtext book (pp501-504 in your LINUX book. Create two unidirectional pipes to implement two-way communication between the parent and a child.

Explanation / Answer

Ans.2) I will start with this first, to understand how actually pipe works.

First of all it is a just technique to facilitate communication between two or more processes.Communication you can say is like sending/recieving any kind of values or data .one process can give its output to another process as input and furthur processing is done on this input and output is given.

As mentioned in example above :

who | wc -l

here output of who command is given to command "wc -l" which in turns give line count of output given by "who" command. Here output of 'who' command is passed to command 'wc -l' .two different program(process) who and 'wc -l' .who gives user names and this is passed to wc -l command and it will count all line given by who command so that we can know how many user are there.

Ans.1) two type of pipe is used : Named and Unnamed.

Unnamed : as the name suggest pipe with no name.it is used within life of processes. in above example pipe or all shell pipe is unnamed it is used with command and output is given and process finished so that pipe. in programming context we need to call pipe() system call . system call is function defined in header file and already implemented OS related task.

two ends of pipe is used as one for read and other for write.read() system call is used for read and another end call write() system call to write . close() system is used to close both end of pipe one by one.

Named:-it has "name" and it exists in our file system untill and unless we remove it using command 'rm' and in programming context 'unlink()' system call is used. it is created using mknode() system call or 'mknod' command on shell.

Ans3)

Ans4) since unnamed pipe is unidirectional pipe .one end is for read and another is for write.so we need to use 2 unnamed pipes, p and q for communication between two processes .

Next, it links the parent and child process using two pipes. Pipe p: Parent to Child and Pipe q: Child to Parent.

Child sends responses through Pipe q and receives command from parent by Pipe p.