Docsity

Scalable Sync on Shared Memory Multiprocessors: Algorithms & Performance Comparison, Papers of Operating Systems

Partial preview of the text

Download Scalable Sync on Shared Memory Multiprocessors: Algorithms & Performance Comparison and more Papers Operating Systems in PDF only on Docsity!

Scalable Synchronization onShared Memory Multiprocessors • Paper discusses several algorithms forimplementing spinlocks and barriers;includes performance discussion on twotypes of hardware

Intro

•^ Why need synchronization contructs in thekernel? •^ Can a mutex be sufficient?

Basic sync constructs • Blocking – may be too heavy • Busy-waiting – Benefits when? • Built on top of some atomic instructions supported byhardware – Different on different platforms • test-and-set() • fetch-and-store(R, ) • fetch-and-add(, ) • compare-and-swap(, <cmp-val>, <stor-val>) – Execution costly – typically atomic instruction costs more cyclesthan a regular one

Basic spin-lock

-^ Using atomic test_and_set operation^ init^

lock = clear; lock while(t&s(lock) == busy); /* spin */ unlock lock = clear;

-^ Where is lock? •^ Do we have to spin on the shared variable (and the atomicinstruction)? •^ What is the architecture like?^ –^ Bus-based vs. Interconnection network^ –^ Local caches? Cache-coherency?^ •^ Write-update (Broadcast)^ •^ Write-invalidate

Reduce contention approach –Backoff delay type lock^ =^ (unlocked,

locked) procedure^ acquire_lock(L:^lock)^ delay^ :^ integer

:= while^ test_and_set(L)

=^ locked pause(delay) delay:=delay*2 procedure^ release_lock(L:^lock) lock^:=unlocked • Different processors back-off different amount of timewhen they see lock was busy • Exponential backoff, static backoff… • Delay approaches work for bus-based and interconnectionnetwork based architectures (“dance-hall”) • Problem -?

Reduce waiting time/delay • Can you find out immediately that lock is freed withoutgoing to memory location? • Caches! & cache-coherent architectures • Idea – spin on locally cached value, act when you see achange • Test_and_test&set lock^ while

(lock^ ==^ busy)

spin; if^ (t&s(lock)

==^ busy)^ goto

lock;

-^ What’s behaviour like in Write-Update vs. Write-Invalidate? •^ What if you don’t have hardware supported coherency?Can all local “lock” copies be changed?

Queuing locks

0 • a unique ticket for each arriving processor • get ticket in waiting queue • go into CS when you have lock • signal next waiter when you are done • assume a primitive op r&inc(mem)

……….^ p- flags array

current lock holder^

queuelast

{has-lock,^ must-wait} hl^ mw

Anderson’s array-based queuing lock

again! approach: replace with Regular test_and_set Noone is spinning on next_slot^ make sure it’s^ in different cache^ line/Mm module

Issues with these locks • Proc: FIFO ordering – Delay, resource contention – good • (not in ticket without CCwBroadcast) – Though may be dangerous if process in the queue getscontext switched! – Ticket lock also guarantees FIFO. • Cons: – lock structure size proportional to # of procs. – Latency issue, especially if no r&inc in Anderson,ticket

MCS queuing lock

No compare_and_swap • Doable – but now 2 atomic operations – they areexpensive!

Performance comparisons • BBN Butterfly – Shared mm multiprocessor, up to 256 processor nodes, log

-depth 4

interconnection network – Atomic ops fetch_and_clear_then_add and fetch_and_clear_then_xor; maskused to implement other ops, including fetch_and_add; – Atomic ops very expensive compared to regular operations • Sequent Symmetry – Shared bus multiprocessor, up to 30 nodes – Write-invalidate cache-coherency – Fetch_and_store supported; other logical/arithm ops can be applied atomicallybut do not return a value (e.g., incr vs. read_and_incr) – Atomics cheaper • Neither supports compare_and_swap • Single processor #s: