Presentation is loading. Please wait.

Presentation is loading. Please wait.

Critical Section Tools (HW interface) locks implemented in ISA – T&S, CAS (O.S. )Semaphores – Counting and Binary (a.k.a a mutex lock) (Augmented O.S.)

Similar presentations


Presentation on theme: "Critical Section Tools (HW interface) locks implemented in ISA – T&S, CAS (O.S. )Semaphores – Counting and Binary (a.k.a a mutex lock) (Augmented O.S.)"— Presentation transcript:

1 Critical Section Tools (HW interface) locks implemented in ISA – T&S, CAS (O.S. )Semaphores – Counting and Binary (a.k.a a mutex lock) (Augmented O.S.) Monitors & conditions – Java, C#, or make your own! Need only atomic lock ops at the ISA level, implement the rest yourself. But, as more tools are offered by the kernel, the OS will expand its role here, offering easier-to-use or optimized solutions – Win and Pulse example

2 Critical Section A section of code that shares data with other concurrent threads Sharing of data makes a section critical – Specifically, write contention In a kernel, many shared data structures – Need to synchronize these to guard against race conditions – OR, make kernel thread scheduling non- preemptive

3 How to Make an Atomic Exchange Try: MOVE $s3, $a1 ;move swap val into $s3 LL $s2, 0($s1) ; load linked SC $s3,0($s1) ; store conditional BEQZ $s3, try ;sc returns success in $s3 MOVE $v1, $s2 ;return load result ;simple atomic exchange ; if the contents of $s1 change between the LL and the SC? SC fails and returns 0. – Similar in spirit to return address verification ; note: context switch between LL and SC? SC fails and returns 0 in $s3 then

4 Another Lock: fetch-and-increment Try: LL $t2, 0($t1) DADDUI $t3, $t2, 1 ;our increment SC $t3, 0($t1) BEQZ $t3, try ;branch if store fails


Download ppt "Critical Section Tools (HW interface) locks implemented in ISA – T&S, CAS (O.S. )Semaphores – Counting and Binary (a.k.a a mutex lock) (Augmented O.S.)"

Similar presentations


Ads by Google