Managing the peripherals

The terms I will discuss today are:

  1. Second Memory (the hard-disk)
  2. Managing the swap space
  3. Building a better disk

1. Second memory 

  • Structure
  • Scheduling
  • Managing

The peripherals are divided according to functionality in :

  • I/O peripherals
  • Storing peripherals

according to it’s operating manner in :

  • dedicated (only for one process)
  • shared (one or more processes)

according to it’s transfer manner in :

  • character ( views info as a long byte array, e.g. printer,  keyboard, mouse)
  • block ( hard – disk, transfers de information between main memory and second memory through blocks, small pieces of data)

according to it’s access time variation in :

  • direct accessed (time variation differs a bit)
  • complete direct accessed (time variation is stable)
  • sequential accessed (the time variation differs a lot)

The magnetic disks are viewed as a long unidimensional array of blocks.

Bellow is a drawing of a hard-disk.

Hard disk schematic

The disk speed depends on:

  • seek time
  • rotation latency
  • transfer time

( ! ) the disk total access time is the sum of the above.

Issues regarding the hard-disk speed:

  • Scheduling the access to disk
  • Writing data to disk
  • Building a better disk

a) Scheduling the access to disk

The OS is responsible for the efficient using of the hardware: for the hard-disk this resumes to having a fast access time and a big bandwidth.

The bandwidth represents the number of bits transferred divided by the time between the moment when the request was sent till the moment when the request was resolved.

For a better and efficient way of using the hard-disk some engineers thought about implementing the following algorithms regarding the way of serving the requests:

  • FCFS (First Come, First Served)
  • SSTF (Shortest Seek Time First)
  • SCAN
  • C-SCAN
  • LOOK
  • C-LOOK

I. FCFS

– we can observe the requests are resolved sequentially basing on the order of request income.

– this brings a total read/write head movement of 640 cylinders

II. SSTF

– we can see the algorithm chose the request with the shortest distance to the current position

– this algorithm brings a short access time but neglects the priority requests

III. SCAN

The scan algorithm permits the read/write head to  scan the whole disk from one edge to the other resolving the requests as it moves..

IV. C – SCAN

It’s working the same way as the SCAN algorithm does, except that when it reaches one of the edges, it turns back immediately without scanning through it’s way back.

V. LOOK and C – LOOK

The look and the C-look are an optimization of the Scan and C-Scan

3. Managing the disk

The disk is divided in small pieces called sectors. This operation is called low-level formatting and is made in the factory before selling the disk. The last 30 years, each sector was build to “hold” 512 bytes, but recently it can “hold” 4 kb.

MBR ( Master Boot Recorded) partitioning:

( ! ) This is the standard partitioning schema for the PC (bios)

A disk partitioned with the MBR schema will look like this:

  • the first track will be reserved (63 sectors of 512 bytes)
  • maximum 4 primary partitions and one extended
  • the first sector of the 63 sectors is called MBR sector

The MBR sector looks like this:

  • first 446 bytes  hold the bootstrap loader program 
  • the next 64 hold the partition table
  • the last 2 bytes hold the signature (55AA)

For a better relocation of the stored blocks, the OS uses a FFS (Fast File System): the related blocks are grouped so later on the seek time can be shortened.

3. Managing the Swap Space

The swap space is an extension of the main memory.

  • Under UNIX the swap space is stored in a different partition, or disk.
  • In Windows the swap space is stored in files

4. Building a better disk

Better, in terms of disk optimization, means more density (more bytes on square centimeter: nowadays there can be more than 30 billion bits per square centimeter stored).

The solution: RAID (Redundant Array of Independent Disks):

  • has multiple disks
  • uses the data striping ( storing data of the same process on different disks)

Personal consideration – I believe the flash memory will replace soon the disk based memory, meaning that it’s useless to invest in a RAID technology