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

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

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
Image of page 1

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

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
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '10
  • DR
  • dentist, Semaphore dentist

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern