Summary of Basic Knowledge of Operating System (6) - Device Management

1. Disk structure

  • Platter : a disk has multiple platters;
  • Track (Track) : a circular band-shaped area on the disk, a disk can have multiple tracks;
  • Sector (Track Sector) : An arc segment on a track, a track can have multiple sectors, it is the smallest physical storage unit, currently there are mainly two sizes of 512 bytes and 4K;
  • Magnetic head (Head) : very close to the disk surface, capable of converting the magnetic field on the disk surface into an electrical signal (reading), or converting an electrical signal into a magnetic field on the disk surface (writing);
  • Brake arm (Actuator arm) : used to move the head between tracks;
  • Spindle : Make the entire disk rotate.

2. Disk scheduling algorithm

The factors affecting the time to read and write a disk block are:

  • Rotation time (the spindle rotates the platter so that the head moves to the appropriate sector)
  • Seek time (moving the brake arm so that the head moves to the proper track)
  • actual data transfer time

Among them, the seek time is the longest, so the main goal of disk scheduling is to minimize the average seek time of the disk .

2.1 First Come First Served FCFS, First Come First Served

Scheduling occurs  in the order of disk requests .

The advantages are fairness and simplicity . The disadvantage is also obvious, because the seek is not optimized, so the average seek time may be longer.

2.2 The shortest seek time first SSTF, Shortest Seek Time First

The track with the closest distance to the track where the current head is located is prioritized .

Although the average seek time is relatively low, it is not fair enough . If a newly arriving track request is always closer than a waiting track request, then the waiting track request will wait forever, that is, starvation will occur. Specifically, track requests at both ends are more prone to starvation.

3.3 Elevator Algorithm SCAN

The elevator always keeps running in one direction until there is no request for that direction, and then changes the running direction.

The elevator algorithm (scanning algorithm) is similar to the operation process of the elevator. It always performs disk scheduling in one direction until there are no outstanding disk requests in this direction, and then changes the direction.

Because the direction of movement is considered, all disk requests will be satisfied, which solves the starvation problem of SSTF.

 

References:

  • Tanenbaum A S, Bos H. Modern operating systems[M]. Prentice Hall Press, 2014.
  • Tang Ziying, Zhe Fengping, Tang Xiaodan. Computer Operating System[M]. Xidian University Press, 2001.
  • Bryant, RE, & O'Hallaron, DR (2004). Deep understanding of computer systems.
  • Stevens. Advanced Programming in UNIX Environment [M]. People's Posts and Telecommunications Press, 2014.
  • Decoding UCS Invicta – Part 1

Guess you like

Origin blog.csdn.net/daydayup858/article/details/129353595