The program shows basic pipe usage in UNIX. In the program, parent process writes a message...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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\n", inbuf); } return 0; 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\n", inbuf); } return 0;
Expert Answer:
Related Book For
Posted Date:
Students also viewed these general management questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Suppose that the stock price S, follows lognormal distribution St= Soe(a-8-0.50) t+oiz Prove that the conditional expectation of lognormal prices, when terminal stock price ST falls below Kis where d...
-
Dollar General Corporation, headquartered in Goodlettsville, Tennessee, is an aggressive competitor in the deep discount retail industry, fighting for position with other stores such as Family...
-
An employee received the following benefits: regular compensation income, net of P25,000 SSS, PHIC & HDMF employee share - P850,000; 13th month pay - P120,000; De minimis benefits within their limits...
-
The harmonic decomposition problem considered by Pisarenko can be expressed as the solution to the equation. The solution for a can be obtained by minimizing the quadratic form a*l?yya subject to the...
-
What are the maximum postponed gain or loss and the basis for the replacement property for the following involuntary conversions? Type of Conversion Amount Adjusted Realized Amount Reinvested...
-
If the stiffness of spring the Hartnell governor is increased, the governor will become: (a) More sensitive (b) Less sensitive (c) Remain same (d) None of these
-
Name and describe the four major sets of variables that might be used in segmenting consumer markets. Which segmenting variables does Starbucks use?
-
Elizabeth Burke has asked you to do some preliminary analysis of the data in the Performance Lawn Equipment database. First, she would like you to edit the worksheets Dealer Satisfaction and End-...
-
An agency's productivity has fluctuated as follows during the last four years: During year 2, productivity increased 4% from year 1. During year 3, productivity decreased 2% from year 2. During year...
-
Statement of Comprehensive Income for the year ended 31 December 2022 Sales (all credit) Cost of sales Opening inventory Purchases (all credit) Closing inventory Gross profit Statement of Financial...
-
(1) Life on a medieval estate centered on the castle, the residence of the lords family and refuge for the estates population in time of war. (2) After Christian crusaders had studied Byzantine and...
-
Explain why empowerment is so important to supervisors, employees, and organizations, individually and as a whole. Please share/provide some firsthand examples from your work or social experiences....
-
1) Explain why the war in Ukraine was expected to drive food prices up. Use a graph or graphs to support your answer. 2) In addition to the war, what other factors were expected to contribute to an...
-
Name and describe the good or service you have selected. Include the brand name. Describe how this good or service is used. Describe at least three inputs needed to produce this good or service....
-
The data below are the calories and grams of sugar in some popular store bought cookies. Calories 143 Grams of Sugar 12 97 9 200 11 149 19 84 4 57 9 198 21
-
Use nodal analysis to determine voltages v1, v2, and v3 in the circuit Fig. 3.76. Figure 3.76 4 S 3i, 2 A 4A
-
What is meant by expedited arbitration?
-
Describe some of the characteristics of Canadian union members and unionized workplaces. Choose at least one of these characteristics and explain what you think are the reasons for this...
-
The Teaching Assistants Union at Civic University represents teaching assistants, markers, and sessional (contract) instructors. It also represents instructors in two programs offered by the...
-
Figure 10.40 shows a negative feedback control system. a. Design a P controller such that the damping ratio of the closed-loop system is 0.5 . b. Estimate the rise time, overshoot, and \(2 \%\)...
-
Consider the feedback system shown in Figure 10.26. a. Using Routh's stability criterion, determine the range of the control gain \(K\) for which the closed-loop system is stable. b. Use MATLAB...
-
The transfer function of a dynamic system is given by \[G(s)=\frac{s+1}{4 s^{4}+5 s^{3}+2 s^{2}+s+6} \] a. Using Routh's stability criterion, determine the stability of the system. b. Using MATLAB,...
Study smarter with the SolutionInn App