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)
The image contains a code snippet written in C that demonstrates the use of POSIX threads also known as pthreads The program initializes a volatile in... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
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...
-
Find the mean and standard deviation for the numbers of sleepwalkers in groups of five. Refer to the accompanying table, which describes the numbers of adults in groups of five who reported...
-
A real estate investor collects the following data on a random sample of apartments on the west side of College Station, Texas. a. Plot the data as a scatter diagram with Y = rent and X = size. b....
-
Discuss how the concepts of groupthink and escalation of commitment might be related to some cases of unethical decision making (and its cover-up) in business.
-
Barts Company has prepared the fixed asset and depreciation schedule shown in Exhibit DC13-2. The following information is available: The land was purchased eight years ago when Building 1 was...
-
Write a python on below requirenment 12.11 LAB: Parsing food data Given a text file containing the availability of food items, write a program that reads the information from the text file and...
-
A company has a loan with a face value of $100,000 and an annual interest rate of 5%. The loan is to be repaid in 5 years. Instructions: Calculate the annual loan payment using the formula PMT = PV *...
-
You are an administrator at a local not-for-profit (501(c)(3)) hospital. The accounting team is preparing an IRS Form 990 for the current tax year but would like to confirm with the administrative...
-
reword Due to the novelty of this service, we encountered some difficulties in uploading all employee information. As a result, Curai will have to manually set up an account for you. I have emailed...
-
1 points Item 14 Companies using a perpetual inventory system: Multiple Choice still need to count the physical inventory occasionally. never physically count their inventory. always know the actual...
-
Marta and Shanika decide to open a computer repair shop. They agree that Marta will manage their parts inventory and all of the accounting duties. Shanika will work out front and meet with customers...
-
AI, rewrite, I have been with CBRE for over five years providing administrative support to various departments, legal, corporate responsibility, CBRE Cares and currently the People Team. I am...
-
How is the implementation of Supply Chain Management Department Store based on system design problems?
-
Should we separate the debt and equity features of convertible debt? Team 1: Pro separation: Present arguments in favor of separating the debt and equity features of convertible debt. Team 2: Against...
-
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;
-
Visit the Bloomberg Markets website at www.bloomberg.com/markets/stocks. Their interactive graph allows you to see cumulative returns for individual stocks as well as market indices. Over the last...
-
Eugene Fama and Robert Shiller recently won the Nobel Prize in economics. Go to http://nobelprize.org/nobel_prizes/economics/ and locate the press release on Eugene Fama and Robert Shiller. What was...
-
What are the implications of behavioral finance?
Study smarter with the SolutionInn App