Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following C program and declarations are part of the next problem. For each part, the three comment lines ? ? * * L I

The following C program and declarations are part of the next problem. For each part, the three comment
lines
??**LINE1**?
??**LINE2**?
will be replaced with different fragments of code. (For space reasons, we are not checking error return
codes, so assume that all functions return normally.)
int counter -2
void foo
counter ++
printf ("%id", counter):
int maino {
pthread_t tid[2]:
int i :
for
??**LINE1**?
??**LINE2**?
1**LINE3**
}
counter++
counter"+: printf("%g", counter):
(Feel free to remove this page from your exam packet for easy reference.)
Problem 7.(8 points):
This problem tests your understanding of the differences between processes and threads.
Part 1
Suppose the following code replaces the three comment lines in the program on the previous page:
LINE 1
LINE 2
Pthread_create(&tid [i],0, foo, 0):
What is the first number that gets printed on stdout? Circle only one answer.
3
45
Could be elther 3 or 4 or 5
Could be elther 3 or 4
Part 2
Suppose the following code replaces the three comment lines.
LINE 1: Pthread_create (&tid [i],0, foo, 0):
LINE 2: Pthread_join(tid [i], O):
What is the first number that gets printed on stdout? Circle only one answer.
3
345
Could be elther 3 or 4 or 5
Could be elther 3 or 4
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions