Computers and Technology

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 17:00, carealee
How should you set the ohms adjust control on a multitester of analog vom, for resistance measurements?
Answers: 1
image
Computers and Technology, 22.06.2019 15:00, miracle9704
Atool that matches persoal skills qualities interests and talets to a career is called a
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, devnnn44
What is the original authority for copyright laws
Answers: 1
image
Computers and Technology, 24.06.2019 12:00, violetagamez2
What is a sketch or blueprint of a web page that shows the structure (but not the detailed design) of basic page elements such as the logo, navigation, content, and footer?
Answers: 3
Do you know the correct answer?
You are given a new atomic primitive, called FetchAndSubtract(). It executes as a single atomic inst...

Questions in other subjects: