Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

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

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions