Another ExampleAwaiting an Event
Task Issues Call to OS for Disk Read
The application program calls the OS requesting that a block of data be read from a disk drive into memory. Once a disk read request is forwarded to the disk interface, the disk read/write head mechanism must be positioned over the target disk cylinder. This is a lengthy mechanical process typically requiring milliseconds to complete. When the head mechanism has positioned the read/write heads over the target cylinder, the disk interface must then wait for the start sector of the requested block to be presented under the read head. The duration of this delay is defined by the rotational speed of the disk drive as well as the circumference of the cylinder. Once again, this is a lengthy delay that can be measured in milliseconds. Only then can the data transfer begin.
Rather than awaiting the completion of the disk read, the OS would better utilize the machine's resources by suspending the task that originated the request and transferring control to another program so work can be accomplished while the disk operation is in progress.
OS Suspends Task
As described earlier, the processor saves its current state (i.e., its register image) in a special area of memory set aside for this task (the task's TSS). Once this series of memory write transactions has completed, the task has been suspended.
OS Initiates Disk Read
The OS issues a disk read command to the disk controller. The disk controller begins to seek the heads to the target cylinder.
OS Makes Entry in Event Queue
The OS makes an entry in its event queue. This entry will be used to transfer control back to the suspended task when the disk interface completes the transfer.
OS Starts or Resumes Another Task
Rather than waiting for the completion of the disk read operation, the OS will start or resume another task.
Disk-Generated Interrupt Causes Jump to OS
When the disk controller (or, in older machines, its associated DMA channel) completes the transfer of the requested information into system memory, it generates an interrupt request. This causes the processor to jump to the disk driver's interrupt service routine which checks the completion status of the disk operation to ensure a good completion.
Task Queue Checked
The OS then scans the event queue to determine which suspended task is awaiting this completion notification.
OS Resumes Task
The OS causes the processor to reload the suspended task's stored register image (its TSS) into the processor's registers. The processor then uses CS:EIP to determine what memory address to fetch its next instruction from. The resumed task then processes the data in memory that was read from the disk.