1 / 5

Condition variables

Condition 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;} } release(tt_lock);}. proc wait(cvar, lock) {

mala
Download Presentation

Condition variables

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. Condition variables

  2. 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;} } release(tt_lock);}

  3. proc wait(cvar, lock) { acquire(tt_lock); ttable[id].lock  lock; ttable[id].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); ttable[id].lock  lock; ttable[id].cvar  cvar; ttable[id].sp  SP; ttable[id].state  WAITING; // other yield code release(tt_lock); enable_interrupts;}

More Related