Sunteți pe pagina 1din 2

Assignment 4 1/2 CMPT 300 E200, Fall 2010

1. [4 points] Given two processes A and B, and semaphores res1 and res2, which of the
following cases are prone to deadlocks and which are deadlock-safe? Why?

void procA( ) { void procA( ) { void procA( ) { void procA( ) {


semWait(&res1); semWait(&res1); semWait(&res1); semWait(&res1);
semWait(&res2); semWait(&res2); semWait(&res2); semWait(&res2);
useBothRes( ); useBothRes( ); useBothRes( ); useBothRes( );
semSignal(&res2); semSignal(&res2); semSignal(&res1); semSignal(&res1);
semSignal(&res1); semSignal(&res1); semSignal(&res2); semSignal(&res2);
} } } }
void procB( ) { void procB( ) { void procB( ) { void procB( ) {
semWait(&res1); semWait(&res2); semWait(&res1); semWait(&res2);
semWait(&res2); semWait(&res1); semWait(&res2); semWait(&res1);
useBothRes( ); useBothRes( ); useBothRes( ); useBothRes( );
semSignal(&res2); semSignal(&res1); semSignal(&res1); semSignal(&res2);
semSignal(&res1); semSignal(&res2); semSignal(&res2); semSignal(&res1);
} } } }
(a) (b) (c) (d)

2. Consider the following graph:


a. [2 points] Based on what you have learned in class,
explain what the graph means?
b. [2 points] Is there a deadlock? Why or why not?
c. [2 points] Name the four necessary conditions for
deadlocks. Do they hold here?
d. [2 points] What needs to be changed in this graph so
that these conditions are sufficient for a deadlock?

3. [6 points] Consider a system that has a total of r resources of a certain type available (e.g. it
has r CD-drives), and it has p processes each requiring at most m of those resources. Find a
condition to guarantee the system is not prone to deadlocks?

4. A system has four processes and five allocatable resources. The current allocation and
maximum needs are as follows:

Process R C
A 1 1 2 1 3 1 0 2 1 1 A=[0 0 a3 1 1]
B 2 2 2 1 0 2 0 1 1 0
C 2 1 3 1 0 1 1 0 1 0 E=[e1 e2 e3 e4 e5]
D 1 1 2 2 1 1 1 1 1 0

a. [3 points] What is the smallest value of a3 for which this is a safe state?
b. [3 points] What are the smallest possible values for e1 … e5?
Assignment 4 2/2 CMPT 300 E200, Fall 2010

5. [2 points] Given the speeds listed in Fig. 5-1, is it possible to scan documents from a scanner
and transmit them over an 802.11g network at full speed? Defend your answer.

6. [4 points] In which of the four I/O software layers is each of the following done.
a. Computing the track, sector, and head for a disk read.
b. Writing commands to the device registers.
c. Checking to see if the user is permitted to use the device.
d. Converting binary integers to ASCII for printing.
(Hint: Only three layers are used here, so consider one of the layers for two cases.)

7. [5 points] A local area network is used as follows. The user issues a system call to write data
packets to the network. The operating system then copies the data to a kernel buffer. Then it
copies the data to the network controller board. When all the bytes are safely inside the
controller, they are sent over the network at a rate of 10 megabits/ sec. The receiving network
controller stores each bit a microsecond after it is sent. When the last bit arrives, the
destination CPU is interrupted, and the kernel copies the newly arrived packet to a kernel
buffer to inspect it. Once it has figured out which user the packet is for, the kernel copies the
data to the user space. If we assume that each interrupt and its associated processing takes 1
msec, that packets are 1024 bytes (ignore the headers), and that copying a byte takes 1 µsec,
what is the maximum rate at which one process can pump data to another? Assume that the
sender is blocked until the work is finished at the receiving side and an acknowledgement
comes back. For simplicity, assume that the time to get the acknowledgement back is so
small it can be ignored. Also ignore any other overhead not stated above.

8. [3 points] RAID level 3 is able to correct single-bit errors using only one parity drive. What
is the point of RAID level 2? After all, it also can only correct one error and takes more
drives to do so.

9. [9 points] Consider a magnetic disk consisting of 16 heads and 400 cylinders. This disk is
divided into four 100-cylinder zones with the cylinders in different zones containing 160,
200, 240, and 280 sectors, respectively. Assume that each sector contains 512 bytes, average
seek time between adjacent cylinders is 1 msec, and the disk rotates at 7200 RPM. Calculate
the (a) disk capacity, (b) optimal track skew, and (c) maximum data transfer rate.

10. [3 points] Most people still remember the Y2K problem. Some expect a similar problem that
may arise for UNIX systems. Many versions of UNIX use an unsigned 32-bit integer to keep
track of the time as the number of seconds since the origin of time (by convention, January 1,
1970). (a) When will these systems wrap around (year and month)? (b) What about wrap
around time for systems that use a signed 32-bit integer instead? (c) Suggest a way of fixing
this problem when the wrap around time arrives.

S-ar putea să vă placă și