

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























-^ 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
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 -?
(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?
……….^ p- flags array
current lock holder^
queuelast
{has-lock,^ must-wait} hl^ mw
again! approach: replace with Regular test_and_set Noone is spinning on next_slot^ make sure it’s^ in different cache^ line/Mm module
-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: