Dekker’s Algorithm, testAndSet, swap, and the semaphore operations P and V may all be used to enforce mutual exclusion. Compare and contrast these various schemes. Consider their respective advantages and disadvantages.

What will be an ideal response?


Dekker’s Algorithm can be implemented without hardware support, but it only provides mutual exclusion for two threads. testAndSet and swap require hardware support, so they might not be as portable. However, using testAndSet or swap to implement mutual exclusion requires much less code than Dekker’s Algorithm. The difference between testAndSet and swap is extremely subtle. Both testAndSet and swap take in two arguments. However, testAndSet always sets the second variable to be true after execution while swap sets the second variable to be the value of the first argument before the call. These two are interchangeable when used for mutual exclusion. Semaphore operations P and V are higher-level mutually exclusive primitives.They require mutual exclusion to already be performed by another primitive that is used in the implementation of P and V.

Computer Science & Information Technology

You might also like to view...

Why is one condition on line 4 “i is greater than -1”?

``` 1 for each j, from 1 to the length of A – 1 2 temp = A[ j ] 3 i = j – 1 4 while i is greater than -1 and A[ i ] is greater than temp 5 A[ i + 1 ] = A[ i ] 6 i— 7 A[ i + 1] = temp ``` A. -1 is not a valid index of an array B. if i has been set to -1, it means the array is already sorted C. if i is -1, we cannot do any more one-assignment swaps, so we must exit the loop D. if i is -1, it means the array cannot be sorted

Computer Science & Information Technology

A security ____________________ defines the boundary between the outer limit of an organization's security and the beginning of the outside world.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

If the system cannot find an activity to handle an Intent’s action, then method startActivity throws an Activity-NotFound-Exception. You can prevent this exception from happening by first using Intent method ________ to determine whether there is an Activity to handle the Intent.

a. findActivity b. findActivityForIntent c. resolveActivity d. resolveActivityForIntent

Computer Science & Information Technology

When used with ofstream objects, operator! is not:

a. Overloaded. b. Used to determine if the open operation succeeded. c. Used to close a file explicitly. d. Used to return a nonzero value if an error occurs.

Computer Science & Information Technology