Bounded Buffer

produce(item)

{

   if (num==N) prod.wait;

   num++; add item to buffer;

   cons.signal;

};

 

 

 

consume(item);

{

   if (num==0) cons.wait;

   num--; get item from buffer;

   prod.signal;

};

 

Reader-Writer (CORRECT)

ReadEntry()

if (wc>0 || wwc>0) {

        rwc++; read.wait; rwc--;

}

rc++;

read.signal;

 

ReadExit()

rc--; if (rc==0) then write.signal

 

WriteEntry()

if (rc>0) || (wc>0) {

    wwc++; write.wait; wwc--

}

wc++;

 

WriteExit()

wc--;

if (rwc>0} read.signal else write.signal 

Dining Philosopher. No deadlock, but starvation

pickup(i)

 

  while !(chp[left] && chp[right])

                           self[i].wait;

  chp[left] = false; chp[right] = false;

 

 

putdown(i)

 

  chp[left]=true;  signal(self[left]);

  chp[right]=true; signal(self[right]);