1. Operating Systems Team: Jonathan Arturo Alvarado Mata 1441616 Obed David Guevara Ibarra 1447478 Carlos Eduardo Triana Sarmiento 1412573 Blog: http://os-ocj.blogspot.com/
2.
3.
4.
5.
6. CONSUMER(){ while(1){ // try to aquire the lock if(l1->TRYAQUIRE()){ // if the array is empty, wait // if it isn’t, continue... WHILE(ARRAY == EMPTY){ C->WAIT(L1); } // decrease the number of items in the array CONSUME(); C-> SIGNALl(); // Enables the waiting thread L1->RELEASE(); } // end of if } // end of while } //end of function consumer
7. void main(){ L1 = new lock(“L1”); C = new condition(“C”); Thread *t = new Thread(“producer”); t->Fork(producer, 1); Thread * t= new Thread(“consumer”); t->Fork(consumer, 1); }end main