What outputs will be at Line C and Line P? Why ? #include #include #include int...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
What outputs will be at Line C and Line P? Why ? #include <pthread.h> #include <stdio.h> #include <types.h> int value = 0; void *runner (void *param); /* the thread */ int main(int argc, char *argv[]) { pid_t pid; pthread_t tid; pthread_attr_t attr; pid = fork(); if (pid } == = 0) { /* child process */ } pthread_attr_init(&attr); pthread_create(&tid, &attr, runner,NULL); pthread_join(tid, NULL); printf("CHILD: value = %d", value); /* LINE C */ } else if (pid > 0) { /* parent process */ wait (NULL); printf("PARENT: value= %d", value); /* LINE P */ void *runner (void *param) { value = 5; pthread_exit (0); What outputs will be at Line C and Line P? Why ? #include <pthread.h> #include <stdio.h> #include <types.h> int value = 0; void *runner (void *param); /* the thread */ int main(int argc, char *argv[]) { pid_t pid; pthread_t tid; pthread_attr_t attr; pid = fork(); if (pid } == = 0) { /* child process */ } pthread_attr_init(&attr); pthread_create(&tid, &attr, runner,NULL); pthread_join(tid, NULL); printf("CHILD: value = %d", value); /* LINE C */ } else if (pid > 0) { /* parent process */ wait (NULL); printf("PARENT: value= %d", value); /* LINE P */ void *runner (void *param) { value = 5; pthread_exit (0);
Expert Answer:
Answer rating: 100% (QA)
The provided image contains a C program that utilizes both process and thread creation mechanisms The fork system call is used to create a new process ... View the full answer
Related Book For
Computer Systems A Programmers Perspective
ISBN: 9781292101767
3rd Global Edition
Authors: Randal E. Bryant, David R. O'Hallaron
Posted Date:
Students also viewed these programming questions
-
Define operator o on functions as: (fog)(x) : R R, f(x) = x + 2x + 1; and g: R R, g(x) = 2. = f(g(x)). Define (a) Please compute fog and go f, respectively; (b) Please determine whether f and g are...
-
Assignment 5: Hash Table implementation andconcordance There are three parts to this assignment. In the first two parts,you will complete the implementation of a hash map and aconcordance program. In...
-
In Exercises 118, find the distance between each pair of points. If necessary, express answers in simplified radical form and then round to two decimals places. (2.6, 1.3) and (1.6, -5.7)
-
Reece's parents made a trust deposit of $500 on October 31, 2004, to be withdrawn on Reece's twenty-first birthday on July 31, 2025. What will be the value of the deposit on that date at 7%...
-
The treasurer of Amaro Canned Fruits, Inc., has projected the cash flows of Projects A, B, and C as follows: Suppose the relevant discount rate is 12 percent per year. a. Compute the profitability...
-
Identify the research scenario, including the general area of focus. Develop a hypothetical research scenario that would necessitate the use of the Mixed Method A-B-A Design. The research will be...
-
At the beginning of the year, Plummer's Sports Center bought three used fitness machines from Advantage, Inc. The machines immediately were overhauled, installed, and started operating. The machines...
-
*7. Verify the divergence theorem (i.e. show in the mathematical statement of the theorem that LHS = RHS) for the vector field A = 2xzi+zxj + (z xyz + 2)k, : and the region in z 0 enclosed by x +...
-
(d) Consider the following piece of JavaScript code: function sumOfArray(array, l, r) { if (1>r) { } return 0; } else if (1 ==r) { return array[1]; } var m= Math.floor((1+r)/2): var sumL = sumofArray...
-
what entities are currently supported by national aeronautics and space administration (NASA) delegations? (select three) atlas launch systems, orbital science commercial resupply service for the...
-
we have a assignment on social media threat on companies reputation and we want a purpose statement with these guidelines BUSINESS COMMUNICATION PROCESS PERDUCT Introductions in a Formal Report:...
-
What is a random variable? How would you differentiate a discrete from a continuous random variable? A laptop manufacturing company has implemented a 2-step process to test the quality of each...
-
What are the wicked problems that Jabulani experiences from the following story? Jabulani lives on the streets in Hillbrow. He has been a "stroller" for more than three years and has learned to...
-
What are the four strategies for responding to Negative Risks? What are the four strategies for responding to opportunities? What is Residual Risk? What is Secondary Risk?
-
Tourists demand in the market is estimated to be, QT(P) = 1500P Locals demand in the market is estimated to be, QL(P ) = 4000 4P (where P represents the price of a ticket in dollars) It is estimated...
-
Draw the appropriate control flow graph of the given pseudocode.Make sure to only use one number for blocks of code which are all sequential and when the first line is executed, all of those lines...
-
Consider a function P, which generates local values, named a0a8. It then calls function Q using these generated values as arguments. Gcc produces the following code for the first part of P: A....
-
Suppose that a and b have byte values 0x55 and 0x46, respectively. Fill in the following table indicating the byte values of the different C expressions: Expression a & b alb -al-b a & b Value...
-
Figure 3.21 C and assembly code for while version of factorial using guarded-do translation. The fact_while_gd_goto function illustrates the operation of the assembly-code version. We can see that...
-
Which of the following statements regarding applications of ETFs in portfolio management is correct? A. Equity ETFs tend to be more active than fixed-income ETFs. B. The range of risk exposures...
-
Which of Stosurs statements regarding ETF mechanics is correct? A. Statement 1 B. Statement 2 C. Statement 3 Howie Rutledge is a senior portfolio strategist for an endowment fund. Rutledge meets with...
-
Factor (smart beta) strategy ETFs are least likely to be used by investors: A. to modify portfolio risk. B. for tactical trading purposes. C. to seek outperformance versus a benchmark.
Study smarter with the SolutionInn App