Lec29-Semaphores III

Lec29-Semaphores III - National University of Computer...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Operating System Operating System Spring 09 Spring 09 National University National University Lec29-Semaphores III Lec29-Semaphores III Prepared by Prepared by Uzma Maroof Uzma Maroof [email protected] [email protected]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 int BUFFER_SIZE = 100; int count = 0; void producer(void) { int item; while(TRUE) { produce_item(&item); empty->P(); CountMutex->P(); enter_item(item); CountMutex->V(); full->V(); }} void consumer(void) { int item; while(TRUE) { full->P(); CountMutex->P(); remove_item(&item); CountMutex->V(); empty->V(); consume_item(&item); Semaphore Empty(BUFFER_SIZE); Semaphore full(0); Semaphore CountMutex(1); What will happen if we swap empty->P(); CountMutex- >P();
Background image of page 2
int BUFFER_SIZE = 100; int count = 0; void producer(void) { int item; while(TRUE) { produce_item(&item); CountMutex->P(); empty->P(); enter_item(item); CountMutex->V(); full->V(); }} void consumer(void) { int item; while(TRUE) { full->P(); CountMutex->P(); remove_item(&item); CountMutex->V(); empty->V(); consume_item(&item); Semaphore Empty(BUFFER_SIZE); Semaphore full(0); Semaphore CountMutex(1); Suppose the buffer is full Where is the producer??? Where is the consumer???
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2011 for the course COE 10001 taught by Professor Abad during the Spring '09 term at Alfaisal University.

Page1 / 14

Lec29-Semaphores III - National University of Computer...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online