30 points, due Mar. 28, 2011
- An alternative to the TAS instruction is the FAI (Fetch And Increment)
instruction. Here are its semantics:
int FAI(int& val)
return val++; // Performed atomically.
Devise a solution to the critical section problem for processes using
this instruction. Model your solution on the manner in which a bakery, for
instance, serializes customer service by means of a number dispenser.)
Show that your solution is, in fact, a solution to the critical section
- A barbershop consists of a waiting room with N chairs, and the barber
room containing the barber chair. If there are no customers to be served
the barber goes to sleep. If a customer enters the barbershop and all
chairs are busy, then the customer leaves the shop. If the barber is busy,
then the customer sits in one of the available free chairs. If the barber
is asleep, the customer wakes the barber up. Write pseudo-code for the
cooperating barber and customer threads. In devising your solution, you
may make use of queueing semaphores.
- Consider the following set of processes:
Draw four Gantt charts illustrating the execution of these processes using
preemptive), preemptive SJF, non-preemptive priority (a smaller
priority number implies a higher priority), and RR (quantum = 1).
Also, for each scheduling algorithm, answer the following:
Which algorithm results in the smallest average waiting time?
- What is the turnaround time of each process?
- What is the waiting time of each process?
Thomas P. Kelliher