Operating System Review 4.2.0 - Disk Organization and Management

disk structure

disk, track, sector

The disk is divided into n circles of tracks, and each track is divided into multiple sectors
insert image description here

Disk read and write

The magnetic head moves to the track where the sector to be read and written is located to complete the reading and writing.
The disk rotates so that the target sector passes under the magnetic head

Disk and Cylinder

insert image description here

Classification

Classification by heads: retractable and non-retractable heads (multiple heads on the same disk)
Classification by disks: fixed disks with non-replaceable disks and replaceable disks with replaceable disks

Disk Scheduling Algorithm

Disk read and write time-consuming

seek time/seek time

When reading and writing data, the time it takes to move the head to the specified track: start the head arm, move the head
T = start the head arm time + cross a track time * cross the number of tracks
Seek time is related to the disk scheduling algorithm

delay

By rotating the disk, it takes time to position the head to the target sector. If the disk speed is r, the average delay time required is 1/2 * 1/r, that is, 1/2 revolution divided by the speed

transmission time

It takes time to read and write data from the disk, set the speed r, the number of read and write bytes b, the number of bytes on each track n, T = 1/r * b/n is linearly related to the speed, that is, it is related to the hardware, and the operating
system Cannot optimize

FCFS

insert image description here

SSTF

insert image description here

SCAN

insert image description here

LOOK

insert image description here

S-SCAN

insert image description here

C-LOOK

insert image description here

Summarize

FCFS first-come-first-serve has a fair attribute, but it will be tired of seeking when the accessed tracks are scattered, and
SSTF will give priority to the tracks closest to the head to ensure that each seek time is short, but starvation may occur, and The overall time may not be optimal.
SCAN returns every time it scans to the track boundary. The average seek time is short, and it is not hungry, but the movement is forced to touch the boundary to change the direction. The uneven track response frequency LOOK solves the scanning direction of
SCAN The problem is that if there is no other request in the moving direction, change the moving direction of the head.
S-SCAN solves the uneven response frequency of SCAN to each track. On the basis of returning when it hits the boundary, it adds that it does not process any requests until it returns. The C-LOOK at the starting end
is based on S-SCAN and does not need to touch the boundary before returning

Disk reduces latency

If the read sectors are distributed continuously, it will cause a waste of time
because after the head reads the data, it takes time to process the data, and at this time the disk continues to rotate, and it can only continue to read when it is turned under the head next time, which increases the delay. time

alternate number

Logically adjacent sectors are physically separated to reduce latency

Misplaced naming

insert image description here
insert image description here

Design of Disk Address Structure

insert image description here
Convenient and continuous reading according to (cylinder number, disk number, sector number)

disk management

disk initialization

insert image description here
Physical Formatting -> Disk Partitioning -> Logical Formatting

boot block

When the computer is turned on, it needs to perform a series of initialization work by executing the initialization program (bootloader). The
bootloader program is stored in the boot block (boot block/boot partition) of the disk, and the
disk with the boot partition is called the boot disk and the system.
Only a very small bootloader program is stored in the disk ROM. Run this program first when starting up. Through this program, you can find the boot block and read the complete bootloader program into the memory to complete the initialization .

bad block

Sectors that cannot be used normally are bad blocks, which cannot be repaired by the system, so they need to be marked

For simple disks, you can check the entire hard disk for bad blocks during logical formatting, and mark bad sectors in the FAT table.
For complex hard disks, there is a disk controller inside the disk to maintain a bad block list, and the disk is physically formatted before leaving the factory. Initialize the bad block chain when it is converted, and reserve some spare sectors for replacing bad blocks

Guess you like

Origin blog.csdn.net/weixin_51109304/article/details/130961900