Lesson 4b Flashcards
Parallel Systems
What is a mutex
Mutual exclusion lock. Only one thread can access
What is a semaphore
A shared lock multiple threads can access data “Multiple readers”
Barrier Synchronization?
You have a location that other threads will wait for until all of them reach the location “Host wait until everyone is at the restaurant”
Atomic Instructions
Load-and-store, read-and-inc, etc…
What is all that is needed from the instruction set for barrier sync?
atomic read and write
what is rmw instruction?
Read-Modify-Write. Needed to set a value that is also being checked. If(i == 0) i = 1; this needs to happen atomically.
Different types of RMW
Test-and-set, Fetch-and-inc, fetch-and-0
Scalability issue with barrier sync
latency, waiting time, contention
What is spin lock on test and set?
if locked){while(locked){…} locked = 1; /* testAndSet in the while condition */
what is spin on read?
waiters spin on cached copy of L. Doesn’t create contention on network. /Checking local cache/ while(L == locked){ if (test-and-set(L) == locked) go back
How do we avoid contention when a lock is released
spin lock with delay
Can all processors have the same delay value?
No, this will cause the same contention that working from a regular spin lock would cause
What happens with delay that has exponential backoff
On each lock in the while loop the length of the delay is doubled. While(TestAndSet(L) == locked){ delay(d); d = d * 2; }
What is an important problem with spin lock?
Fairness, spin lock doesn’t guarantee that the original requester will get the lock first
what is the ticket lock similar to in daily life?
A ticket system at the deli. If you get ticket 16 you have to wait from stay ticket 5 until 16. Anyone that comes after you will need to wait to order.