sol-Tutorial4

sol-Tutorial4 - Question 1 This implementation supports: -...

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

View Full Document Right Arrow Icon
Question 1 This implementation supports: - Mutual exclusion: as protected by the binary semaphore, once a philosopher successfully gets pass the wait(sem) operation, this guarantees that he is exclusively in the critical section (and enjoys having his meal). - Deadlock: as only one philosopher can enter the critical section, no hold and wait situation could be happened; hence, this implementation is free of deadlock. - Starvation: because of the use of busy waiting in the semaphore, this would have a chance of having starvation for unlucky philosopher(s). - Performance: poor performance as only one philosopher can enter the critical section; in other words, no concurrency at all. Question 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Semaphore patient = 0; //counting semaphore to count Semaphore dentist = 0; //binary semaphore - indicate whether the dentist is available or not Semaphore lock = 1; //act as a mutex lock Semaphore emptychair = 0; //wait for the dental chair to become not occupied int patient_count = 0; //indicate how many patients in the clinic waiting to be served
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/01/2010 for the course CS 2342 taught by Professor Dr during the Spring '10 term at HKU.

Page1 / 4

sol-Tutorial4 - Question 1 This implementation supports: -...

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

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