Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program shows basic pipe usage in UNIX. In the program, parent process writes a message to pipe and child process reads the message

 

The program shows basic pipe usage in UNIX. In the program, parent process writes a message to pipe and child process reads the message from pipe and prints it to screen. Let's assume that a process forks two child processes (C1, C2). Then, three processes communicate with each other in a circular fashion as shown in the right figure. The parent process (P) sends data to the first child process (C1), this one sends the same data to the second child process (C2), and eventually, the second one sends the same data back to the parent process (P). a) How many pipes do you define? Explain your reasoning. b) Write the code to implement this inter-process communication case. O C1 #define MSGSIZE 5 int main() { char inbuf [MSGSIZE]; int p[2], pid, nbytes; if (pipe (p) < 0) exit (1); if ((pid = fork ()) > 0) { write (p[1], "Hello", MSGSIZE); wait (NULL); } else { read (p[0], inbuf, MSGSIZE); printf("%s ", inbuf); } return 0;

Step by Step Solution

3.54 Rating (147 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Industrial Relations in Canada

Authors: Fiona McQuarrie

4th Edition

978-1-118-8783, 1118878396, 9781119050599 , 978-1118878392

More Books

Students also viewed these General Management questions

Question

What is meant by expedited arbitration?

Answered: 1 week ago

Question

Solve the following the equation. 8-0.5(x+3)=0.25(x-1)

Answered: 1 week ago

Question

Solve the following the equation. x- 0.025x=341.25

Answered: 1 week ago