Critical section tools
Download
1 / 4

Critical Section Tools - PowerPoint PPT Presentation


  • 88 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Critical Section Tools' - genero


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
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.

      • 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


Critical section
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


How to make an atomic exchange
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


Another lock fetch and increment
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


ad