Assignment 6, due Sept. 28
Part of
the homework for 22C:112, Fall 2012
|
On every assignment, write your name legibly as it appears on your University ID and on the class list! Assignments are due at the start of class on the day indicated (usually Friday). Exceptions will be by advance arrangement unless there is what lawyers call "an act of God" (something outside your control). Homework must be turned in on paper, either in class or in the teaching assistant's mailbox. Never push late work under someone's door!
if (a == b) thing1(); if (!strcmp(a, b)) thing2();
a) Under what circumstances does the first if statement execute thing1()? (0.4 points)
b) Under what circumstances does the second if statement execute thing2()? (0.4 points)
a) The above linear ordering is stupid. What is the most sensible order? (0.4 points)
Hint: If the sectors are read in a sensible order, the latency (sum of rotational and head positioning latency) should be near-minimal. The sensible order should also remain sensible if you enlarged the disk to have a realistic and useful number of sectors per track, tracks per cylinder, and cylinders. Please ignore any restrictions on reading consecutive sectors on one track, or alternatively and equivalently, assume that interleaving, if required, is done in the hardware.
b) Given the constants SURFACES, CYLINDERS, and SECTORS (per track, for the latter), write a C function linearize(surface,track,cylinder) that produces a linear disk address from the indicated surface, track and cylinder numbers. (0.3 points)
c) Given the constants SURFACES, CYLINDERS, and SECTORS (as in the previous part), write expressions to convert the linear disk address linear to the three variables that make up a disk address, surface, cylinder, and sector. (0.3 points)
There are two possible insertion rules: Given a request for disk address a, it is inserted just before the lowest item already in the queue that has an address greater than or equal to a, or it is inserted just after the highest item in the queue that has an address less than or equal to a.
A question: Which of the above is correct, and what could go wrong with the other alternative. (0.5 points)