Sample Solutions to Midterm #1
You can ask the TAs or me (Ed) for more detailed explanations during office hours; however, all mark changes must go through me.
Page 2
Q1. d, e
Q2. e
Q3. a,b,c,e
Page 3
Q4.
a) ( 16,384 sectors/track / 4 sectors/page ) = 4,096 pages/track
4,096 pages/track * 16 tracks/cyl * 50 rec/page = 3,276,800 rec/cyl
b) Seektime=1ms+(3,000cyl/500cyl)*1ms=(1+6)ms=7ms Rotational delay time = 0.0
Transfer time = 2 revolutions (or spins) where 1 spin is:
16,000 revolutions / minute = 1 min / 16,000 rev = 60 seconds / 16,000 rev = 0.00375 sec/rev = 3.75 ms/rev
Therefore, total access time = 7 ms + 0 + (2 * 3.75 ms) = 14.5 ms
c) 1ms+1/3*(32,000–1)*(1ms/500cyl)+1/2spin = 1 ms + 21.3 ms + 1/2 * (3.75 ms)
= 24.2 ms
Page 4
Q5
a) In the table below, the first LHS column of numbers represents one possible
solution of many to the first part of this question, but you must make sure that the transition from that first column to the second column (i.e., the column we
1
supplied) actually works. For example, specifying 50 / 1 for Frame 1 in the first numeric column won’t work because of the page fault shown in the next column.
“Y” (for page fault) in the first column depends on the circumstances; for example, 22 / 1 could have been a second read of page 22.
The LHS numeric column was worth 2 marks.
The remaining columns were worth 3 marks in total.
Ref. String
22
50
40
40
12
88
Frame 1
79 /0
50 /1
50 /1
50 /1
50 /0
88 /1
Frame 2
33 /0
33 /0
40 /1
40 /1
40 /0
40 /0
Frame 3
22 /1
22 /1
22 /1
22 /1
12 /1
12 /1
Page Fault?
Y
Y
Y
N
Y
Y
b)
Reference String
246w
88
360
404w
Frame 1
777 0/1
777 0/1
360 1/0
360 1/0
Frame 2
246 1/1
246 1/1
246 0/1
246 0/0*
Frame 3
404 0/0*
88 1/0
88 0/0
404 1/1
Page Fault? (y or n)
Y
Y
Y
Y
Which page do we write out, if any, at this point?
none
404
777
none
Page 5 Q6.
3.5 ms/rev = 1 rev / 3.5 ms = x rev / 60,000 ms (because there are 60,000 ms in 60 seconds or 1 minute)
Solve for x. Therefore, x = 17,143 rev/min.
2
Q7.
floor( 0.7 * 4,096 bytes/page) ) = 2,867 bytes/page (of available space) floor( 2,867 bytes/page / 30 bytes/rec ) = 95 rec/page
ceiling( 500,000 rec / 95 rec/page ) = 5,264 pages
How many free pages (i.e., blank pages) do we need if we have 5,264 data pages?
floor( 5,264 / 19 ) pages = floor( 277.05 pages ) = 277 blank pages The required sum is therefore (5,264 + 277) pages = 5541 pages.
Page 6 Q8.
a) floor( 0.82 * (4,096 bytes/page) ) = 3,358 bytes/page (of available space) floor( 3,358 bytes/page / 14 bytes/rec ) = 239 rec/page
b) floor(4,096bytes/page/(4+(25+2)+(50+2)+3)bytes/rec) = floor( 4,096 bytes/page / 86 bytes/rec )
= 47 rec/page
c) (4 + (15 + 2) + (22 + 2) + 3) / (4 + 25 + 50 + 3) = 48/82 = 0.59 And 1.00 – 0.59 = 0.41.
This means there is a 41% savings.
(We gave 2 out of 3 marks for 41/75 = 0.546 for a 45% savings.)
(It would be OK if you did the calculation based on a comparison of how many records of these lengths actually fit on one page.)
3
Page 7 Q9.
a)
Note that we need 1 ms setup time, plus 2 ms per 1,000 cylinders moved.
At time t = 0, the list has only one request: {9,000}. We head in that direction from cylinder 5,000.
o Moving from cyl 5,000 → cyl 9,000 takes:
1 ms + 4 * (2 ms) + 1⁄2 * (6 ms) rotational delay
= (9 + 3) ms = 12 ms ……………………………… t = 12 ms (so far)
At t = 8, a request for cyl 5,000 arrived—long after we passed it at t = 0.
So, we have a service request for only cylinder: {5,000}. Let us head in that direction.
o Let’s start moving from cyl 9,000 → cyl 5,000.
o Weuseup1ms+2*(1ms)=3mstoarriveatcyl8,000,butthat’swhen
we get a new request for cyl 7,000. In other words, this is at time t = 15. o This interrupts our trip to cyl 5,000. Let us service 7,000 along the way. o Moving from cyl 8,000 to cyl 7,000 requires an additional 2 * (1 ms) = 2
ms,plustheusualrotationaldelayof1⁄2*(6ms)=2ms+3ms=5ms. In other words, we took 3 ms + 5 ms = 8 ms in total to get here from cyl 9,000.
o Therefore,t=12ms+8ms=20ms………………….t=20ms(sofar)
Note that a new request arrived at t = 18, but well after we passed it. It’s for cyl 8,000.
Therefore, the request list now holds {5,000, 8,000).
Using the elevator algorithm, we continue to go from cyl 7,000 to cyl 5,000.
o Weuseup1ms+ 2*(2ms)+1⁄2(6ms)=8ms…… t=28ms(sofar) Now, the request list has only cyl {8,000} left.
o Weuseup1ms+3*(2ms)+1⁄2(6ms)=10ms…… t=38ms(finish)
Page 8 Q10.
SELECT FROM WHERE
ORDER BY
TSNAME, ICTYPE, COPYPAGESF, DSNAME, TIMESTAMP SYSIBM.SYSCOPY
DBNAME = ‘ACCOUNT’
AND
(ICTYPE = ‘F’ OR ICTYPE = ‘I’)
TIMESTAMP DESC; — same as: ORDER BY 5 DESC;
4