Adding System Calls We want to allow user programs to access the hard disk safely. Add two system calls that allow reading and writing of individual blocks. Disks come in lots of different shapes and sizes, so we'll also need some facility for the user program to inquire the geometry of the disk. Add two system calls that report the number of blocks on the disk and the number of bytes in a disk block. Multiple processes may be requesting service from the disk, so you will have to schedule access to ensure safety and good performance.
Programs tend to request the same blocks of a disk over and over again.
The kernel can help speed things up by making a buffer cache of Kernel.bufferSize disk blocks. Before queuing a readDiskBlock request for the disk, check to see whether the block is already in the cache. If so, simply copy the user's data to or from the cached copy. If not, allocate a slot in the cache, queue a request to read a block into the cache, and finish the user's request when the read has finished. For writeDiskBlock requests, simply copy the user's data into the cache entry for the block, allocating a new cache entry if necessary.