The positioning time, or random-access time, consists of two parts: the time necessary to move the disk arm to the desired cylinder, called the seek time, and the time necessary for the desired sector to rotate to the disk head, called the rotational latency
A disk drive is attached to a computer by a set of wires called an I/O bus.
Several kinds of buses are available, including advanced technology attachment (ATA), serial ATA (SATA), eSATA, universal serial bus (USB), and fibre channel (FC).
The data transfers on a bus are carried out by special electronic processors called controllers.
The host controller is the controller at the computer end of the bus.
A disk controller is built into each disk drive
4 of 16
Disk scheduling
If the drive or controller is busy, any new requests for service will be placed in the queue of pending requests for that drive.
For a multiprogramming system with many processes, the disk queue may
often have several pending requests.
Thus, when one request is completed, the operating system chooses which pending request to service next.
How does the operating system make this choice?
Any one of several disk-scheduling algorithms can be used
The SSTF algorithm selects the request with the least seek time from the current head position.
In other words, SSTF chooses the pending request closest to the current head position.
For our example request queue, the closest request to the initial head position (53) is at cylinder 65.
Once we are at cylinder 65, the next closest request is at cylinder 67.
From there, the request at cylinder 37 is closer than the one at 98, so 37 is served next. Continuing, we service the request at cylinder 14, then 98, 122, 124, and finally 183
SSTF scheduling is essentially a form of shortest-job-first (SJF) scheduling; and like SJF scheduling, it may cause starvation of some requests
Although the SSTF algorithm is a substantial improvement over the FCFS algorithm, it is not optimal
7 of 16
SCAN scheduling
In the SCAN algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests as it reaches each cylinder, until it gets to the other end of the disk. At the other end, the direction of head movement is reversed, and servicing continues. The head continuously scans back and forth across the disk.
The SCAN algorithm is sometimes called the elevator algorithm
Let’s return to our example to illustrate. Before applying SCAN to schedule the requests on cylinders 98, 183, 37, 122, 14, 124, 65, and 67, we need to know the direction of head movement in addition to the head’s current position.
Assuming that the disk arm is moving toward 0 and that the initial head position is again 53, the head will next service 37 and then 14. At cylinder 0, the arm will reverse and will move toward the other end of the disk, servicing the requests at 65, 67, 98, 122, 124, and 183 (Figure 10.6)
8 of 16
Circular SCAN (C-SCAN) scheduling is a variant of SCAN designed to provide a more uniform wait time. Like SCAN, C-SCAN moves the head from one end of the disk to the other, servicing requests along the way.
When the head reaches the other end, however, it immediately returns to the beginning of the disk without servicing any requests on the return trip
9 of 16
More commonly, the arm goes only as far as the final request in each direction.
Then, it reverses direction immediately, without going all the way to the end of the disk.
Versions of SCAN and C-SCAN that follow this pattern are called LOOK and C-LOOK scheduling, because they look for a request before continuing to move in a given direction
10 of 16
Disk formatting
Before a disk can store data, it must be divided into sectors that the disk controller can read and write.
This process is called low-level formatting, or physical formatting
Low-level formatting fills the disk with a special data structure for each sector. The data structure for a sector typically consists of a header, a data area (usually 512 bytes in size), and a trailer
The header and trailer contain information used by the disk controller, such as a sector number and an error-correcting code (ECC)
When the controller writes a sector of data during normal I/O, the ECC is updated with a value calculated from all the bytes in the data area
11 of 16
Most hard disks are low-level-formatted at the factory as a part of the manufacturing process
The operating system still needs to record its own data structures on the disk. It does so in two steps.
The first step is to partition the disk into one or more groups of cylinders.
The operating system can treat each partition as though it were a separate disk
The second step is logical formatting, or creation of a file system. In this step, the operating system stores the initial file-system data structures onto the disk
These data structures may include maps of free and allocated space and an initial empty directory
12 of 16
Some operating systems give special programs the ability to use a disk partition as a large sequential array of logical blocks, without any file-system data structures.
This array is sometimes called the raw disk, and I/O to this array is termed raw I/O
13 of 16
Boot block
For a computer to start running—for instance, when it is powered up or rebooted—it must have an initial program to run.
This initial bootstrap program tends to be simple.
It initializes all aspects of the system, from CPU registers to device controllers and the contents of main memory, and then starts the operating system.
To do its job, the bootstrap program finds the operating-system kernel on disk, loads that kernel into memory, and jumps to an initial address to begin the operating-system execution.
For most computers, the bootstrap is stored in read-only memory (ROM).
14 of 16
Most systems store a tiny bootstrap loader program in the boot ROM whose only job is to bring in a full bootstrap program from disk.
The full bootstrap program can be changed easily: a new version is simply written onto the disk.
The full bootstrap program is stored in the “boot blocks” at a fixed location on the disk.
A disk that has a boot partition is called a boot disk or system disk
The Windows system places its boot code in the first sector on the hard disk, which it terms the master boot record, or MBR.