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
-
Cellular Montana Alta is a business managed by Maneco and Viroldo. The average sales price of cell phones is $ 765.00. The average variable cost per unit is $ 255. For each unit sold, sellers are...
-
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)
-
Telemark-Kjemi AS manufactures an industrial solvent in two departments - mixing and cooking. This question focuses on the Cooking Department. During June 2015, 90 tonnes of solvent were completed...
-
In the circuit, the capacitor is initially uncharged. At t = 0, switch S is closed. Find the currents I 1 and I 2 and voltages V 1 and V 2 (assuming V 3 = 0) at points 1 and 2 at (a) t = 0 (i.e.,...
-
If a company with a 12/31 year-end lends money in the form of a 6-month note on 11/1, which accounts will be credited when the note is paid off on 4/30?
-
This problem continues with the business of Pure Water, Inc., begun in the continuing problem in Chapter 1. Here you will account for Pure Water, Inc.s transactions using formal accounting practices....
-
Question 8 of 12 < D Cullumber Company Balance Sheets December 31 2025 2024 Cash $19,500 $39,000 Accounts receivable (net) 75,000 54,000 Inventory 61,000 48,000 Plant assets (net) 240,000 230,000...
-
Emily Jackson (Social Security number 765-12-4326) and James Stewart (Social Security number 466-74-9932) are partners in a partnership that owns and operates a barber shop. The partnerships first...
-
A drug that exhibits one-compartment pharmacokinetics and is administered by an IV bolus dose. if the drug has a t/2 = 7.5 hr, what is the percentage (%) of the dose remaining in the body 7.0 hours...
-
Under the assumption of Actual factory overhead cost 4,000 and Applied factory overhead cost 3,500 calculate over or under factory overhead cost and show the correction journal entry.
-
Cause of the Wars of Independence in Colonial Spanish create a presentation highlight key points , also please add citations and refences
-
3. Give a full proof outline (under partial correctness) obtained by expansion of the partial proof outline below. Use backward assignment whenever possible. Give a brief explanation on each logical...
-
Make reasonable assumption with documented support about the activities involve in the value chain of Nike production. Identify and suggest type of software available to implement and evaluate the...
-
A company purchased $ 6 0 0 of supplies on credit. Identify the general journal entry below that the company will make to record the transaction.
-
The elements X and Y form compounds having molecular formula XY and XY4. When dissolved in 20 gm of benzene, 1 gm XY, lowers the freezing point by 2.3C, whereas 1 gm of XY lowers the freezing point...
-
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...
-
Net sales, net income, and total assets for Azbell Shipping, Inc., for a five-year period follow: {Requirements} 1. Compute trend percentages for each item for 2017 through 2020. Use 2016 as the base...
-
The financial statements of Adventure News, Inc., include the following items: {Requirements} 1. Compute the following ratios for 2020 and 2019 a. Current ratio b. Quick (acid-test) ratio c....
-
You have been asked to evaluate two companies as possible investments. The two companies, Norfolk Industries Inc. and Strafford Crystal Limited, are similar in size. Assume that all other available...
Study smarter with the SolutionInn App