15.01.2015 Views

CS381 Homework - Suraj @ LUMS

CS381 Homework - Suraj @ LUMS

CS381 Homework - Suraj @ LUMS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Summer 2005-2006<br />

Total Marks: 40<br />

CS 381<br />

<strong>Homework</strong><br />

Due Date: Thursday, July 06, 2006 @ 5 pm<br />

1. [10]<br />

You are given the following preemptive priority scheduling algorithm based on<br />

dynamically changing priorities. Larger priority numbers imply higher priority. When a<br />

process is waiting for the CPU (in the ready queue, its priority increases at rate A (P' = P<br />

+ A). When it is running, its priority changes at rate B (P' = P + B). The parameters A<br />

and B can be set to give many different scheduling algorithms.<br />

1. What is the algorithm that results from B > A > 0<br />

2. What is the algorithm that results from A < B < 0<br />

2. [10]<br />

A student majoring in anthropology and minoring in computer science has embarked on a<br />

research project to see if African baboons can be taught about deadlocks. He locates a<br />

deep canyon and fastens a rope across it, so the baboons can cross hand-over-hand.<br />

Several baboons can cross at the same time, provided that they are all going in the same<br />

direction. If eastward moving and westward moving baboons ever get onto the rope at the<br />

same time, a deadlock will result (the baboons will get stuck in the middle) because it is<br />

impossible for one baboon to climb over another one while suspended over the canyon. If<br />

a baboon wants to cross the canyon, it must check to see that no other baboon is currently<br />

crossing in the opposite direction. Give the pseudo code that avoids deadlock using<br />

semaphores. Do not worry about a series of eastward moving baboons holding up the<br />

westward moving baboons indefinitely (starvation).<br />

3. [5]<br />

Explain why spinlocks are not appropriate for single processor systems but are often used<br />

in multiprocessor systems.<br />

4. [5]<br />

Explain the differences in degree to which the following scheduling algorithm<br />

discriminate against or in favor of short processes.<br />

• FCFS<br />

• RR<br />

• Multilevel feedback queue


Summer 2005-2006<br />

5. [10]<br />

Consider a system consisting of m resources of the same type being shared by n<br />

processes. Resources can only be requested and released by processes one at a time (i.e.<br />

they are non-sharable type). Show that the system is deadlock free if the following two<br />

conditions hold:<br />

• The maximum need of each process is between 1 and m resources<br />

• The sum of all maximum needs is less than m+n<br />

Hint: Show that the there exists a process P i whose Need i is zero. (I.e. it has at least one<br />

resource it can release and hence the system cannot be in a deadlock state.)<br />

Submission Instructions:<br />

o Instructions about how and where to submit your homework will be posted on the<br />

course website.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!