1 / 4

Critical Section Tools

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.

genero
Download Presentation

Critical Section Tools

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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

More Related