A disk drive is disclosed for executing a preemptive multitasking
operating system comprising tasks of varying priority, including a disk
task for processing disk commands by initiating seek operations and
configuring parameters of a read/write channel, a host task for
initiating disk commands in response to host commands received from a
host computer, a background task for initiating disk commands to perform
background operations including a defect scan of the disk, and an
execution task for arbitrating the disk commands generated by the host
task and the background task and for transmitting the arbitrated disk
commands to the disk task.