The InterlockedExchange function was described in Section 2.3. It has two parameters and behaves like the following atomic function:

The InterlockedExchange function was described in Section 2.3. It has two parameters and behaves like the following atomic function:

LONG InterlockedExchange (LONG* target, LONG newValue) {
LONG temp = *target; *target = newValue; return temp;
}

The following is an implementation of a countingSemaphore using InterlockedExchange():

Best Custom Essay Writing Services | EssayBureau.com

Best Custom Essay Writing Services | EssayBureau.com

Statements

while (InterlockedExchange(const_cast(&mutex),true))

 

{Sleep(0);};

and

mutex = false;

are used to enforce mutual exclusion for permits. In the P() operation,

the statement

while (InterlockedExchange(const_cast(&block),true))

 

{Sleep(0);}

is used to delay threads that are waiting to be awakened by V() operations. In the V() operation, the statement

while (!block) {Sleep(0);};

is used to make sure that block is set to false only when it is true. The initial value of block is true. Block is set to false in order to awaken a delayed thread. After block is set to false, it remains false until a delayed thread executes InterlockedExchange(const cast<>∗> (&block),true). (Then the delayed thread becomes awakened.) If block is false when V() is executed, the previous V() operation has not yet awakened a delayed thread.

(a) Show that the deletion of while (!block) {Sleep(0);} in V() can create an error.

Best Custom Essay Writing Services | EssayBureau.com

find the cost of your paper

Does the information in this chart make a career of being a Java professional seem attractive?

Do you work hard for your money? Java professionals think they do, reporting long working hours at their jobs. Java developers from around the world were surveyed about the number….

The Robotics Manufacturing Company operates an equipment repair business where emergency jobs arrive randomly at the rate of three jobs per 8-hour day.

WOW Problem 11-29 The Robotics Manufacturing Company operates an equipment repair business where emergency jobs arrive randomly at the rate of three jobs per 8-hour day. The company’s repair facility….

Your Own Animation In this lab work are asked to write a GUI application using AWT And Swing.

Your Own Animation In this lab work are asked to write a GUI application using AWT And Swing. Since you are going to have your midterm examination this week, we….