Contact us - +12567847275

Computer Science


Consider how to implement a mutex lock using an atomic hardware instruction. Assume that the following structure defining the mutex lock is available:

typedef struct {

int available;

} lock;


(available == 0) indicates that the lock is available, and a value of 1 indicates that the lock is unavailable. Using this struct, illustrate how the following functions can be implemented using the test and set()

and compare and swap() instructions:

• void acquire(lock *mutex)

• void release(lock *mutex)

Be sure to include any initialization that may be necessary


do {

while (true) {

flag[i] = want in;

j = turn;

while (j != i) {

if (flag[j] != idle) {

j = turn;


j = (j + 1) % n;


flag[i] = in cs;

j = 0;

while ( (j


if ( (j >= n) && (turn == i || flag[turn] == idle))



/* critical section */

j = (turn + 1) % n;

while (flag[j] == idle)

j = (j + 1) % n;

turn = j;

flag[i] = idle;

/* remainder section */

} while (true);

Figure 5.22 The structure of process Pi in Eisenberg and McGuire’s algorithm.



15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.