(20 points) Consider the following program. Assume fork calls are successful, the original process has id...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(20 points) Consider the following program. Assume fork calls are successful, the original process has id 100, and that new processes ids start at 101 with increments of one. The parent of the original process has id 50. Note: getpid() returns the id of the executing process and getppid() returns the id of the parent of the executing process. int main (int argc, char *argv[]) { int i, a, pid; a = 1; for (i=0; i < 3; ++i) { a = a*2; pid = fork(); if (pid == 0) { a = a+1; } else cout < < "A: " < < a < < ", " < < getpid() < < ", < < getppid() < < endl; { wait (NULL); cout < < "B: " < < a < < ", " < < getpid() < < ", " < < getppid() < < endl; } } return (0); } What will be printed when the program executes (that is, give the output)? (20 points) Consider the following program. Assume fork calls are successful, the original process has id 100, and that new processes ids start at 101 with increments of one. The parent of the original process has id 50. Note: getpid() returns the id of the executing process and getppid() returns the id of the parent of the executing process. int main (int argc, char *argv[]) { int i, a, pid; a = 1; for (i=0; i < 3; ++i) { a = a*2; pid = fork(); if (pid == 0) { a = a+1; } else cout < < "A: " < < a < < ", " < < getpid() < < ", < < getppid() < < endl; { wait (NULL); cout < < "B: " < < a < < ", " < < getpid() < < ", " < < getppid() < < endl; } } return (0); } What will be printed when the program executes (that is, give the output)?
Expert Answer:
Related Book For
Discrete and Combinatorial Mathematics An Applied Introduction
ISBN: 978-0201726343
5th edition
Authors: Ralph P. Grimaldi
Posted Date:
Students also viewed these programming questions
-
My goal has been to make this course as close as possible to what you would have experienced in the actual classroom of Labor Management.
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Define the notions of Turing-recognisable language and undecidable language. b) Is L Turing- recognisable? Justify your answer with an informal argument. c) Justify with a formal proof your answer to...
-
What have researchers found about the use of job costing to record the cost of handproducing a bound book?
-
Write the first 4 terms of each sequence. a. u1 = 20 un = un-1 + 6 where n 2 b. u1 = 47 un = un-1- 3 where n 2 c. u0 = 32 un = 1.5 un-1 where n 1 d. u1 = -18 un = un-1 + 4.3 where n 2
-
Both mass and volume can be used to describe the amount of matter present in an object. What physical quantity relates these two concepts?
-
7. ADMINISTRATIVE AGENCIES Congress creates federal administrative agencies with enabling legislation. The Administrative Procedure Act controls how agencies do their work. (p. 90)
-
Blanchard Company's accounts receivable subsidiary ledger reveals the following information: Blanchard Company's receivable collection experience indicates that, on average, losses have occurred as...
-
Complete the Schedule B first, then Schedule 1 , then the Form 1040 down through Line 10 . Then complete the Qualified Dividends worksheet and use that information to complete the rest of the Form...
-
1. To prepare for the meeting, create a summary of the yields of each bond by completing the table shown in Exhibit 13.2. Remember that the YTM of each bond is assumed to be the required rate of...
-
Problem 1-13 (Algorithmic) Micromedia offers computer training seminars on a variety of topics. In the seminars each student works at a personal computer, practicing the particular activity that the...
-
(a) Explain the shortfall of using per capita income in comparing the standards of living of people in different countries. (5marks) (b) Draw a circular flow of income for an open economy and...
-
Criterion Feedback 12/26/22 Your presentation will essentially convey meta data as data about data good. What is missing is an example of an Acme metadata and keyword. Follow this example -ex:...
-
Include detailed calculations and explanation. Please use Australia Tax rate 2022. Thank you Complete the GST Calculation Worksheet and prepare Business Activity Statement for ABC Pty Ltd for the...
-
At the end of the year, SG Manufacturing listed the following account balances in their general ledger after the completion of the closing entries. Common Stock $100,000 Additional Paid in Capital,...
-
4. In your own words, describe what an evanescent wave is and how it can be generated. Then, pick a specific angle of incidence for air (n = 1)/glass (n1 = 1.5) interface that can lead to an...
-
Integration is a vital concept when applied in one?s life. Integrating your life means making ideal choices. Perfect choices on the other go in line with quality decisions. Quality decisions lead to...
-
Annually, the 65 members of the maintenance staff sponsor a "Christmas in July" picnic for the 400 summer employees at their company. For these 65 people, 21 bring hot dogs, 35 bring fried chicken,...
-
Let A, B R, where A = {x|x2 - 7x < -12} and B = {x|x2 - x < 6}. Determine A U B and A B.
-
If a, b are distinct vertices in a connected undirected graph G, the distance from a to b is defined to be the length of a shortest path from a to b (when a = b the distance is defined to be 0). For...
-
What costs are associated with buying a home?
-
What activities are associated with selling a home?
-
State three reasons you should carefully inspect the property you plan to purchase.
Study smarter with the SolutionInn App