Homework
•Strategy: The TD[1..n] is several times larger than the number of processors; system assumes at least 1 producer and 1 consumer
•
Put_Task(a) { 
   slot = Fetch&Add(FF,1);
   if slot == n then Fetch&Add(FF, -n);
   if slot > n then slot = slot - n;
   while TD[slot] != 0 do wait(rand());
   TD[slot] = a;
}
Get_Task { var temp; 
   slot = Fetch&Add(NA,1);
   if slot == n then Fetch&Add(NA,-n);
   if slot > n then slot = slot - n;
   while TD[slot] == 0 do wait(rand());  
   temp=TD[slot]; TD[slot]=0; return temp;
}
Put waits if the slot is
occupied to avoid overrun; Get waits if slot is empty
No task has is “0”