Question: Consider the following pthread function: Assume that flag is a global array of size 2 containing boolean values. Assume that both elements of flag are

Consider the following pthread function:

Consider the following pthread function: Assume that flag is a global array

Assume that flag is a global array of size 2 containing boolean values. Assume that both elements of flag are initialized to false.

Assume that the main function creates two threads to execute the above pthread function. Assume that it passes the argument 0 to the first thread and 1 to the second thread (i.e., my_num would be 0 for the first thread and 1 for the second).

Assume that critical_region() is a function that contains code that accesses shared data and hence needs to be protected via mutual exclusion.

Complete the following sentences based on your observations of the code:

The above thread function [ Select ] ["satisfies", "does not satisfy"] the basic requirement of mutual exclusion (i.e., only one thread executes its critical region at any time).

The above thread function [ Select ] ["satisfies", "does not satisfy"] the requirement of bounded waiting(i.e., neither thread waits forever to execute its critical region).

The above thread function [ Select ] ["has", "does not have"] busy waiting.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!