### CS544, Homework 3

• Question 1 (40 pts)

• Exercise 13.3.1:

• Suppose we are scheduling I/O requests for a disk, and the requests arrives as follows:

 ``` Time of arrival Request for track ----------------------------------------------- 0 msec 8,000 1 msec 48,000 10 msec 4,000 20 msec 40,000 ```

The disk head initially at track 32,000.

The time it takes the disk head to move n tracks is 1 + 0.00025n msec.

The (average) latency and transfer time is total 4.3 msec.

Questions:

• At what time is each request serviced fully if we use the elevator algorithm (it is permissible to start moving in either direction at first).

Indicate the order in which the requests will be satisfied !!!

Answer must be in this form (with dervations !)

Correct solution: (seek is not interrupted by an arrival)

 ``` Request (for track#) Time of completion ------------------------------------------------------------------------ At time 0: serve track 8000 #1 track 8000 0 + (1+0.00025*24000) + 4.3 = 11.3 msec At time 11.3: 4000 has arrived, serve track 4000 next #2 track 4000 11.3 + (1+0.00025*4000) + 4.3 = 17.6 msec At time 17.6: only 48000 has arrived, serve track 48000 next #3 track 48000 17.6 + (1+0.00025*44000) + 4.3 = 33.9 msec At time 33.9: 40000 has arrived, serve track 40000 next #4 track 40000 33.9 + (1+0.00025*8000) + 4.3 = 41.2 msec ```

Acceptable solution: (arrival will interrupt the seek operation - harder to implement)

 ``` Request (for track#) Time of completion ------------------------------------------------------------------------ At time 0: serve track 8000 #1 track 8000 0 + (1+0.00025*24000) + 4.3 = 11.3 msec At time 11.3: 4000 has arrived, serve track 4000 before 48000 because it's "on the same way" (elevator is going down now) #2 track 4000 11.3 + (1+0.00025*4000) + 4.3 = 17.6 msec At time 17.6: only 48000 has arrived, go serve track 48000 next ** We pass track 40000 at time: 17.6 + (1+0.00025*36000) = 27.6 msec < 20.0 msec ** STOP at track 40000 on the way to 48000 - serve 40000 first !!! #3 track 40000 17.6 + (1+0.00025*36000) + 4.3 = 31.9 msec At time 31.9: go serve track 48000 #4 track 48000 31.9 + (1+0.00025*8000) + 4.3 = 39.2 msec ```

• At what time is each request serviced fully if we use the first come, first serve service discipline

Indicate the order in which the requests will be satisfied !!!

Answer must be in this form (with dervations !)

 ``` Request (for track#) Time of completion ------------------------------------------------------------------- #1 track 8000 0 + (1+0.00025*24000) + 4.3 = 11.3 msec #2 track 48000 11.3 + (1+0.00025*40000) + 4.3 = 26.6 msec #3 track 4000 26.6 + (1+0.00025*44000) + 4.3 = 42.9 msec #4 track 40000 42.9 + (1+0.00025*36000) + 4.3 = 57.2 msec ```

• Question 2 (Exercise 13.4.6-8) (30 pts)

• Suppose we are using a RAID level 4 scheme (using even parity) with four data disks and one redundant disk.

Aassume that blocks are a single byte.

Questions:

• Give the block of the redundant disk if the corresponding blocks of the data disks are:

1. 01010110, 11000000, 00111011, and 11111011.

 ``` 01010110 11000000 00111011 11111011 ------------- 01010110 ```

2. 11110000, 11111000, 00111111, and 00000001.

 ``` 11110000 11111000 00111111 00000001 -------------- 00110110 ```

• Suppose that data disk 1 has failed.

Recover the block of that disk under the following circumstances:

• The contents of disks 2 through 4 are 01010110, 11000000, and 00111011, while the redundant disk holds 11111011.

 ``` 01010110 11000000 00111011 11111011 -------------- 01010110 ```

• The contents of disks 2 through 4 are 11110000, 11111000, and 00111111, while the redundant disk holds 00000001.

 ``` 11110000 11111000 00111111 00000001 ------------- 00110110 ```

• Suppose the block on the first disk in part (1) is changed to 10101010.

What changes to the corresponding blocks on the other disks must be made?

1. Originally: 01010110, 11000000, 00111011, and 11111011.

Changed to: 10101010, 11000000, 00111011, and 11111011.

 ``` You also need to update the redundant disk to: 10101010 11000000 00111011 11111011 -------------- 10101010 ```

2. Originally: 11110000, 11111000, 00111111, and 00000001.

Changed to: 10101010, 11111000, 00111111, and 00000001.

 ``` You also need to update the redundant disk to: 10101010 11111000 00111111 00000001 -------------- 01101100 ```

• Question 3 (Exercise 13.7.1-3) (30 pts)

• A patient record consists of the following:

• 3 fixed-length fields: the patient's date of birth, social-security number, and patient ID, each field is 10 bytes long.
• It also has the following 3 variable-length fields: (1) name, (2) address, and (3) patient history.

• If pointers within a record require 4 bytes, and the record length is a 4-byte integer, how many bytes, exclusive of the space needed for the variable length fields, are needed for the record ?

You may assume that no alignment of fields is required.

 ``` We get 10+10+10 = 30 for the fixed-length fields, 4+4 = 8 for the pointers to varying-length Fields, and 4 for the record length. The total is 42 bytes. ```

• A patient record consists of the following:

• 3 fixed-length fields: the patient's date of birth, social-security number, and patient ID, each field is 10 bytes long.
• It also has the following 3 variable-length fields: (1) name, (2) address, and (3) patient history.
• A repeating field that represents cholesterol tests --- Each cholesterol test requires 16 bytes

• Show the layout of patient records if the repeating tests are kept with the record itself.