Lec28-Semaphores II

Lec28-Semaphores II - National University of Computer Emerging Sciences Operating System Operating Spring 09 Lec28-Semaphores II Prepared by Uzma

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 Lec28-Semaphores II Lec28-Semaphores II 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 Producer/Consumer Problem Producer/Consumer Problem Consumer must wait for producer to fill buffers, if none full (scheduling constraint) Producer must wait for consumer to empty buffers, if all full (scheduling constraint) Only one thread can manipulate buffer queue at a time (mutual exclusion) Use a separate semaphore for each constraint
Background image of page 2
Scheduling Constraint 1 Scheduling Constraint 2 Mutual Exclusion P() is a Generalization of Sleep() V() is a Generalization of Wakeup() int BUFFER_SIZE = 100; int count = 0; void producer(void) { int item; while(TRUE) { produce_item(&item); if(count == BUFFER_SIZE) sleep (); enter_item(item); count++; if(count == 1) wakeup(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 / 9

Lec28-Semaphores II - National University of Computer Emerging Sciences Operating System Operating Spring 09 Lec28-Semaphores II Prepared by Uzma

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