Tutorial4 - there are empty chairs or leave the office(if...

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

View Full Document Right Arrow Icon
Tutorial IV November 8, 2010 Question 1 (2006/07 Examination) Consider using a binary semaphore to implement a solution to the Dining Philosophers. The following is the code segment that implements the philosopher’s behavior: Semaphore sem = 1; typicalPhilosopher( ) { think( ); wait(sem); pickUpLeftFork( ); pickUpRightFork( ); eatingSpaghetti( ); putDownLeftFork( ); pickDownRightFork( ); signal(sem); } Assume we are implementing the semaphore’s wait( ) and signal( ) functions with busy waiting. Comment on this approach with respect to mutual exclusion, deadlock, starvation, and execution performance. Question 2 (2000/01 Examination) The following situation takes place in a dentist office: The dentist office has one dentist, one dental chair, and 5 chairs for waiting patients, if any, to sit in. If there are no patients present, the dentist sits down in the dental chair and takes a rest. When a patient arrives, he notifies the dentist. If additional patients arrive while the dentist is working on a patient’s teeth, they either sit down (if
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: there are empty chairs) or leave the office (if all chairs are occupied). You are asked to do process synchronization using semaphores for the dentist and the patients without getting into race conditions. Define the semaphores and their functions together with their initial values clearly and make detail comments of your program. Question 3 (2006/07 Examination) Assume a system with four resource types (A, B, C, and D) and five processes (p , p 1 , p 2 , p 3 , and p 4 ). There are multiple units of each type of resources. Is the state of the system safe with the following resource allocation information? Explain your answer. If the system is safe, show how all processes could complete their execution successfully. If the system is unsafe, show how deadlock might occur. Total Resources A B C D 6 4 4 2 Maximum Claim Process A B C D p 0 3 2 1 1 p 1 1 2 0 2 p 2 1 1 2 0 p 3 3 2 1 0 p 4 2 1 0 1 Current loan Process A B C D p 0 2 0 1 0 p 1 1 1 0 0 p 2 1 1 0 0 p 3 1 0 1 0 p 4 0 1 0 1...
View Full Document

{[ 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