Condition variables - PowerPoint PPT Presentation

About This Presentation
Title:

Condition variables

Description:

... variables. proc notify (cvar) { acquire (tt_lock); for (i = 0 to N-1) do { if (ttable[i].cvar == cvar && ttable[i].state == WAITING) { ttable[i].state RUNNABLE; ... – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 6
Provided by: Lis1
Learn more at: http://web.mit.edu
Category:

less

Transcript and Presenter's Notes

Title: Condition variables


1
Condition variables
2
  • proc notify (cvar)
  • acquire (tt_lock)
  • for (i 0 to N-1) do
  • if (ttablei.cvar cvar
  • ttablei.state WAITING)
  • ttablei.state ? RUNNABLE
  • release(tt_lock)

3
  • proc wait(cvar, lock)
  • acquire(tt_lock)
  • ttableid.lock ? lock
  • ttableid.cvar ? cvar
  • release(tt_lock)
  • yield(WAITING)
  • acquire(lock)

4
Implementing condition variables
  • proc wait(cvar, lock)
  • yield_wait(cval,lock)
  • acquire(lock)

5
Implementing condition variables
  • proc yield_wait(cvar, lock)
  • disable_interrupts
  • acquire(tt_lock)
  • release(lock)
  • ttableid.lock ? lock
  • ttableid.cvar ? cvar
  • ttableid.sp ? SP
  • ttableid.state ? WAITING
  • // other yield code
  • release(tt_lock)
  • enable_interrupts
Write a Comment
User Comments (0)
About PowerShow.com