subject

You are given a new atomic primitive, called FetchAndSubtract(). It executes as a single atomic instruction, and is defined as follows: int FetchAndSubtract(int *location) {
int value = *location; // read the value pointed to by location
*location = value - 1; // decrement it, and store result back
return value; // return old value
}

Write the lock_init(), lock(), and unlock() routines that use FetchAndSubtract() to implement a working lock. Also define a lock_t structure.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:00, daniella0123
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, lopez7512
What is the total resistance in a circuit that contains three 60 ohm resistors connected in a series? a. 20 ohms b. 120 ohms c. 60 ohms d. 180 ohms
Answers: 2
image
Computers and Technology, 23.06.2019 15:20, yeahmaneee
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
image
Computers and Technology, 23.06.2019 16:10, alexis9658
What is the ooh? a. omaha occupation handbook b. online occupational c. occupations online d. occupational outlook handbook select the best answer from the choices provided
Answers: 3
You know the right answer?
You are given a new atomic primitive, called FetchAndSubtract(). It executes as a single atomic inst...

Questions in other subjects:

Konu
Mathematics, 23.12.2020 05:50
Konu
Spanish, 23.12.2020 05:50
Konu
Mathematics, 23.12.2020 05:50
Konu
Mathematics, 23.12.2020 05:50
Konu
Physics, 23.12.2020 05:50
Konu
English, 23.12.2020 05:50