You will be creating subsidiary management plans of a Project Management Plan using the information found in the case study provided (attached). Please, for this assignment, do not take "Assessment….
There is a library study room that can only hold 4 people at a time. A semaphore study is used to ensure that only four people are in the room at one time.
Question 2 (12 marks)
There is a library study room that can only hold 4 people at a time. A semaphore study is used to ensure that only four people are in the room at one time. The code for each of the students is:
wait(study); enter(); signal(study);
(a) There are seven students, A, B, C, D, E, F and G, who want to study. Each student is an instance of the Student class. Demonstrate how the semaphore prevents more than four people being in the room at the same time by giving an example execution trace. Show the value of study after each wait or signal step. Ensure that you state the initial value of study.
If a wait operation executes, indicate whether the process succeeds or is placed in the queue. If a signal operation executes, indicate whether the value is changed or a sleeping process is woken up. (7 marks)
(b) The librarian wants to keep track of how many people use the room. A shared variable count is used for this. Each Student instance increments the count as they enter the room. The Student code is changed to the following:
wait(study); wait(mutex); int c = count; count = c + 1; signal(mutex); enter(); signal(study);
Give an example trace to show what would happen if there was no mutex semaphore but the count was still updated by each Student. Your trace should show how an incorrect value for count could be obtained. (5 marks)