UNIHIVE

Study Hub UNIPORT CSC 394

CSC 394 · Operating Systems

File systems, I/O and disk scheduling

Files and directories, access methods, allocation methods, free-space management, I/O techniques, and disk scheduling algorithms with worked head movements.

Our notes

2 min read

Files

A file is a named collection of related information on secondary storage. Attributes: name, type, size, location, owner, permissions, timestamps. Operations: create, open, read, write, seek, close, delete.

Access methods

  • Sequential: read in order (tapes, logs).
  • Direct (random): jump to any block (databases).
  • Indexed: an index points to blocks.

Directory structures

Single-level (all files in one list) → two-level (one directory per user) → tree-structured (folders within folders, paths like /home/ada/notes.txt) → acyclic graph (shared files through links).

Allocation methods

MethodHowPros / cons
Contiguousfile occupies consecutive blocksfast direct access; external fragmentation, hard to grow
Linkedeach block points to the nextno fragmentation; slow direct access, pointer lost = data lost (FAT is a linked variant with the links in a table)
Indexedan index block lists all the file's blocksfast direct access; index overhead (UNIX inodes use direct, single, double and triple indirect pointers)

Free-space management

Bit map (one bit per block: 1 free, 0 used), linked list of free blocks, grouping, counting.

I/O techniques

  • Programmed I/O: CPU polls the device (busy waiting).
  • Interrupt-driven I/O: device interrupts when ready.
  • DMA (direct memory access): a DMA controller moves whole blocks between device and memory, interrupting once at the end; frees the CPU.
  • Buffering, caching and spooling smooth out speed differences.

Disk access time

Seek time (moving the head to the track) + rotational latency (waiting for the sector to come round) + transfer time. Seek time is the largest, so disk scheduling tries to reduce head movement.

Disk scheduling (worked)

Requests (cylinders): 98, 183, 37, 122, 14, 124, 65, 67; head at 53; cylinders 0-199.

  • FCFS: 53→98→183→37→122→14→124→65→67. Movement: 45 + 85 + 146 + 85 + 108 + 110 + 59 + 2 = 640 cylinders.
  • SSTF (shortest seek time first): 53→65→67→37→14→98→122→124→183. Movement: 12 + 2 + 30 + 23 + 84 + 24 + 2 + 59 = 236. (May starve far requests.)
  • SCAN (elevator), moving towards 0 first: 53→37→14→0, then up 65→67→98→122→124→183. Movement: 53 (down to 0) + 183 = 236.
  • C-SCAN (one direction, then jump back), moving up: 53→65→67→98→122→124→183→199, jump to 0, →14→37. Movement: (199 − 53) + 199 + 37 = 146 + 199 + 37 = 382 (counting the return); gives more uniform waiting times.
  • LOOK / C-LOOK: like SCAN / C-SCAN but turn at the last request instead of the disk edge. LOOK moving down first: 53→37→14, then 65→…→183: 39 + 169 = 208.

SSDs

Solid-state drives have no moving head, so seek-based scheduling matters little; the OS instead manages wear levelling and TRIM.

Exams usually ask: file attributes and operations; access methods; compare allocation methods; inodes; DMA; compute total head movement for FCFS, SSTF, SCAN, C-SCAN and LOOK.

Common mistake: in SCAN, stopping at the last request instead of going to the end of the disk (that is LOOK). Read the question for which one is meant.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All CSC 394 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.