Define rd: the average rotational latency in ms,
hd: the average seek time in ms,
tr: the transfer rate in bytes/ms,
ss: the sector size in bytes, and
cs: the CPU speed in bytes/ms.
Note that cs can be defined as bytes/cycle times
cycles/ms where the former is an attribute of the mix of programs
being run and the latter is an attribute of the CPU.
The optimum sector size is one where the following equation balances:
rd + hd + ss/tr = ss/cs
If this does not balance, either the disk is idle some of the time (it
was faster than necessary), or the CPU is waiting some of the time (the
disk was not fast enough). Note that the both sides of this
equation are in units of milliseconds! This simple check on the
units would have saved many students from grief!
Solving for sector size, we get:
ss = (rd + hd) * ( (cs * tr)/(tr -cs) )
This is a research question, primarily included in the assignment to make students think about the relative importance of the different variables. Here are some example issues to consider:
Procedure interrupt_handler;
begin
disable_interrupts;
if (INREADY = 1) then begin
if not(TSTCHQ(INQUEUE) = FULL) then
ENCHQ(INQUEUE,DATAIN);
INREADY = 0;
end;
if (OUTREADY = 1) then begin
if (TSTCHQ(OUTQUEUE) = EMPTY) then
DATAOUT = NULL
else
DATAOUT = DECHQ(OUTQUEUE);
OUTREADY = 0;
end;
enable_interrupts;
end;
If OUTQUEUE is empty and we don't transmit anything to the terminal and just reset OUTREADY to 0, the interrupt handler will only be called again if a key is pressed.
If no key is pressed and output data is produced, it will not be send to the terminal. One way to overcome this would be to set OUTREADY to 1 whenever output data is produced, but this could be an error if the output device was not actually ready.
In the absence of any other mechanism to wake-up the interrupt handler when there is data to be output, we have no choice but to send Null characters.
In fact, there is an ingenious solution to this problem, involving maintaining, in software, a variable indicating whether the interrupt routine had detected the queue empty condition. If the producer code finds this variable set, it can set OUTREADY to 1, forcing an interrupt after it puts data in the queue. If an input interrupt occurs in the interval between putting data in the queue and setting this flag, however, chaos can result, so it would really be preferable to redesign the hardware, for example, by including separate input-interrupt-enable and output-interrupt-enable bits.