|
Traffic of test & set
- In some machines (e.g., SGI Origin 2000) uncached fetch & op is supported
- every such instruction will generate a transaction (may be good or bad depending on the support in memory controller; will discuss later)
- Let us assume that the lock location is cacheable and is kept coherent
- Every invocation of test & set must generate a bus transaction; Why? What is the transaction? What are the possible states of the cache line holding lock_addr?
- Therefore all lock contenders repeatedly generate bus transactions even if someone is still in the critical section and is holding the lock
- Can we improve this?
Backoff test & set
- Instead of retrying immediately wait for a while
Test & test & set
- Reduce traffic further
- Before trying test & set make sure that the lock is free
Lock: ts register, lock_addr
bez register, Enter_CS
Test: lw register, lock_addr
bnez register, Test
j Lock
- How good is it?
- In a cacheable lock environment the Test loop will execute from cache until it receives an invalidation (due to store in unlock); at this point the load may return a zero value after fetching the cache line
- If the location is zero then only everyone will try test & set
TTS traffic analysis
- Recall that unlock is always a simple store
- In the worst case everyone will try to enter the CS at the same time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|