7.2 Test-And-Set Locks 145 1 public class TASLock implements Lock 2 AtomicBoolea
ID: 3740576 • Letter: 7
Question
7.2 Test-And-Set Locks 145 1 public class TASLock implements Lock 2 AtomicBoolean state new AtomicBoolean(false); 3 public void lock () 4 while (state.getAndSet (true)) ) 6 public void unlock) 7 state.set (false): Figure 7.2 The TASLock class. 1 public class TTASLock implements Lock l 2 AtomicBoolean state new AtomicBoolean (false); 3 public void lock) 4 while (true) f while (state.get()) ( if (Istate.getAndSet (true)) return; 10 public void unlock() ( 11 state.set (false); 12 13 le state set Figure 7.3 The TTASLock class. TTASI ack algorithms are equivalent from the point fuan mutual exclusion.Explanation / Answer
In this problem is based on the locking problem relative the BackoffLock .
Advantage and disadvantage Exponential Backoff relative TTAS lock
Advantage:
1) Exponential backoff is easier as compare to TTAS lock implementaion.
2)Has better performance than TTAS Lock
3) Beats TTAS lock
4) avoid useless invalidations.
Disadvantage
1)must choosen parameter carefully.
2)not portable across different architecture.
Some important points
1)Spinners //below those reason thats why TTAS performs poorly
a)missed in cache
b) Go to bus
2)TTAS waits until lock "locks " free
a) Spin on local cache
b) No bus use while lock busy
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.