Final Exam. May 8, 2001. Question 5
You are given the following type definition:
typedef struct {
int block_number;
char *buf;
int readwrite;
kt_sem sem;
} DT_struct;
You are writing the I/O portion of your subsystem. You are to implement
two subroutines:
-
add_disk_transaction(DT_struct *dts) -- this is called in a clean
thread when a disk transaction needs to be
done. The disk block
number and relevant buffer are given in dts.
Readwrite is zero for
read, and one for write, and sem should be woken up when the
transaction is done.
- disk_done() -- this is called in a clean thread when the disk
finishes a transaction.
And you have access to the following subroutine:
- start_disk(int block_number, char *buf, int readwrite) --
this starts the specified disk transaction and returns. A
disk_done() thread will be forked off by the disk controller
when the transaction is done.
Implement the two subroutines using any one of the disk scheduling
algorithms from the book with the exeception of FIFO scheduling.
State which algorithm you implemented and what its drawbacks are,
if there are any.
You may assume that your thread system uses Kthreads, and is not
preemptive. You may use any global variables that you want.