Consider the program below, concurrent program with multiple threads: volatile int counter = 50; void *worker...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the program below, concurrent program with multiple threads: volatile int counter = 50; void *worker (void*arg) { counter--; return NULL; } int main(int argc, char*argv[]) { pthread_t p1, p2; pthread_create (&p1, NULL, worker, NULL) ; pthread_create (&p2, NULL, worker, NULL); } pthread_join (p1, NULL); pthread_join (p2, NULL); printf("%d ", counter); return 0; Assuming pthread_create () and pthread_join () all work as expected (i.e., they don't return an error), select all possible outputs? 0 49 48 51 50 Consider the program below, concurrent program with multiple threads: volatile int counter = 50; void *worker (void*arg) { counter--; return NULL; } int main(int argc, char*argv[]) { pthread_t p1, p2; pthread_create (&p1, NULL, worker, NULL) ; pthread_create (&p2, NULL, worker, NULL); } pthread_join (p1, NULL); pthread_join (p2, NULL); printf("%d ", counter); return 0; Assuming pthread_create () and pthread_join () all work as expected (i.e., they don't return an error), select all possible outputs? 0 49 48 51 50
Expert Answer:
Answer rating: 100% (QA)
Assuming pthreadcreate and pthreadjoin all work as expected ie they dont ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
2. [-/1.5 Points] DETAILS MY NOTES PRACTICE ANOTHER A production line operation is designed to fill cartons with laundry detergent to a mean weight of 64 ounces. A sample of cartons is periodically...
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
123 Compare the purely graphical properties of these two notations, and the ways in which the graphical properties of each display correspond to the information structure being defined. Describe...
-
The net present value and internal rate of return desirability measures for two mutually exclusive investments being considered by Stockton Corporation to follow. Year NPV IRR R 161 14.60% S 138...
-
A businessman in New York is preparing an itinerary for a visit to six major cities. The distance traveled, and hence the cost of the trip, will depend on the order in which he plans his route. How...
-
Blood contains several substances that minimize changes in its acidity by reacting with either an acid or a base. One of these is the hydrogen phosphate ion, HPO42. Write one equation showing this...
-
A growing corporation in a large city has offered a 200- room hotel a one-year contract to rent 40 rooms at reduced rates of $50 per room instead of the regular rate of $85per room. The corporation...
-
On a cold winter day the temperature is 2C and the relative humidity is 15%. You inhale air at an average rate of 5500mL/min and exhale a gas saturated with water at body temperature, roughly 37C. If...
-
Find the distance between the points (-8, -9) and (20, -9). units Submit
-
We want to design a tension spring with a spring outer diameter of 32 mm. The range of tensile load is 110 160 N, and the deformation range is 140~ 170 mm. We are going to use SWO-B as the material....
-
What are the costs of staffing versus accepting the Gitre proposal? Do you recommend that SMS accept the proposal from Gitre to provide staff and other services to the Visitor Division?
-
The Ste. Marie Division of Pacific Media Corporation just started operations. It purchased depreciable assets costing $47 million and having a four-year expected life, after which the assets can be...
-
Bounce Ltd makes baseballs that sell for $12.50 each. The company's current annual production and sales are 240 000 baseballs. Annual fixed costs are $589,550. Variable costs for each baseball are as...
-
Morison Cars Inc. has a new project with a cost of $480,000 and annual cash flows of $154,000 for 5 years. The cost of capital for the project is 15%. Calculate (i) net present value, (ii) discounted...
-
YTM, YTC, and Current Yield ABC's bonds have a 5.5% coupon and pay interest semi-annually. The bonds are currently selling for $1,150. The bonds mature in 20 years. The bonds can be called in 8 year...
-
TWELVE A chemical compound is made by raw material being processed through two processes. The output of Process A is passed to Process B where further material is added to the mix. The details of the...
-
Ayayai Corporation engaged in the following cash transactions during 2020. Sale of land and building $192,800 Purchase of treasury stock 48,400 Purchase of land 45,800 Payment of cash dividend 85,100...
-
From 1970 to 1990, Sri Lanka's population grew by approximately 2.2 million persons every five years. The population in 1970 was 12.2 million people.What is the best formula for P, Sri Lanka's...
-
For each of the following sets of classes, indicate whether public or private derivation is more appropriate for Column B: A class Bear class Kitchen class Person class Person. class Person, class...
-
Construct function prototypes that match the following descriptions: a. igor() takes no arguments and has no return value. b. tofu() takes an int argument and returns a float. c. mpg() takes two type...
-
Is the following statement valid? If not, why not? If so, what does it do? int x = (1,024); What about the following? int y; y = 1,024;
-
You have been hired by a catalog company to computerize its sales order entry forms. Approximately 60 percent of all orders are received over the tele- phone, with the remainder either mailed or...
-
A well-designed system can prevent both intentional and unintentional alteration and destruction of data. These data controls can be classified as (1) input controls, (2) processing controls, and (3)...
-
Two years ago an external auditing firm supervised the programming of embedded audit modules for Previts Office Equipment Company. During the audit process this year, the external auditors requested...
Study smarter with the SolutionInn App