1. Consider the three conditions for a solution of critical section problem to be a correct solution: Mutual Exclusion, Progress and Bounded Waiting. Please explain
a. Mutual Exclusion: If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.
b. Progress: If no process is execution in its critical section and there exist some processes that wish to enter their critical section, then the selection of the process that will enter the critical section next cannot be postponed indefinitely.
c. Bounded Waiting: A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
2. While Peterson’s solution is correct, please discuss the situation where P1 and P2 are entering the Critical Section at about the same time. How to decide which process can enter its Critical Section?
Before enter its critical section, the process will receive a number. The process which has the smaller number can get in its critical section first.
3. Please specify under what kind of situation where busy waiting can be considered advantageous?
When reader is in busy waiting and writer is using the resource and when writer is in busy waiting, reader is using the resource. It’s less likely to happen the clash of using resource.
4. Consider the reader program of the reader-writer problem below. Please explain
(1) why the readers need to use the semaphore “mutex” but the writers don’t.
(2) why the readers also work on the “wrt” semaphore which is used by the writers.
if (readcount == 1)
reading is performed
if (readcount == 0)
(1). When there’s no data in the buffer, readers need to wait. While the capacity is not limited so writers can keep producing.
(2). Before loading the buffer, it have to do the mutual exclusion.
COPYRIGHT (c) 2016 ePortfolio ALL RIGHTS RESERVED.