Presentation is loading. Please wait.

Presentation is loading. Please wait.

13. Secondary Storage (S&G, Ch. 13)

Similar presentations


Presentation on theme: "13. Secondary Storage (S&G, Ch. 13)"— Presentation transcript:

1 13. Secondary Storage (S&G, Ch. 13)
Operating Systems Certificate Program in Software Development CSE-TC and CSIM, AIT September--November, 2003 13. Secondary Storage (S&G, Ch. 13) Objectives introduce issues such as disk scheduling, formatting, and swap space management

2 Contents 1. A Hard Disk (Again) 2. Disk Scheduling 3. Disk Formatting
4. Boot Blocks 5. Swap Space Management 6. Disk Reliability

3 : 1. A Hard Disk (Again) Fig. 2.5, p.33 spindle track t actuator
sector s read-write head : cylinder c arm platter rotation continued

4 Mapping to the hardware:
The Logical View: one-dimensional array of logical blocks a block is the smallest transfer unit (typically bytes) Mapping to the hardware: for each cylinder (outer to inner) start at first sector of outermost track go round the track move to the next track on the cylinder

5 Mapping Issues Avoiding defective sectors:
use substitutes from elsewhere on the disk The number of sectors varies per track less sectors per track in the centre Zones a zone is a collection of tracks whose sectors/track are the same

6 2. Disk Scheduling Fast access times requires: High disk bandwidth
fast seek time move head to the right cylinder quickly low rotational latency rotate the disk under the head quickly so the required sector can be accessed High disk bandwidth total number of bytes transferred in the time between the initial request and its completion

7 Controller Selection Disk I/O requests are placed on a queue managed by the hard drive controller. When the controller comes to do the next request, its scheduler chooses a request which: improves access time improves disk bandwidth

8 Types of Disk Scheduling
First-Come First-Served (FCFS) Shortest Seek-Time First (SSTF) SCAN (and C-SCAN) LOOK (and C-LOOK)

9 2.1. FCFS Scheduling Fair Not the fastest service
Large swings across the disk are possible. The following example(s) will assume a disk queue of I/O requests to blocks on cylinders.

10 Example Fig. 13.1, p.433 Queue: 98, 183, 37, 122, 14, 124, 65, 67 Head starts at cylinder 53. 14 37 53 65 67 98 122 124 183 Total head movement = 640 cylinders

11 2.2. SSTF Scheduling The next request to be serviced is the one closest to the current head position minimize seek time Reduces overall head movement. May lead to starvation for some requests.

12 Example Fig. 13.2, p.434 Queue: 98, 183, 37, 122, 14, 124, 65, 67 Head starts at cylinder 53. 14 37 53 65 67 98 122 124 183 Total head movement = 236 cylinders

13 Not Optimal If the queue was serviced in a slightly different order:
53, 37, 14, 65, 67, 98, 122, 124, 183 then the total head movement would be less: 208 cylinders

14 2.3. SCAN Scheduling Scan back and forth across the disk
sometimes called the elevator algorithm Problem: if a request arrives just behind the head then it will have to wait until the head returns.

15 Example Fig. 13.3, p.435 Queue: 98, 183, 37, 122, 14, 124, 65, 67 Head starts at cylinder 53, and moves left. 14 37 53 65 67 98 122 124 183 Total head movement = 236 cylinders

16 C-SCAN Scheduling ‘C’ for “circular list”.
When a scan reaches one end of the disk, it jumps to the other end no point reversing since it is unlikely that there will be requests in recently serviced areas

17 Example Fig. 13.4, p.436 Queue: 98, 183, 37, 122, 14, 124, 65, 67 Head starts at cylinder 53, and moves right. 14 37 53 65 67 98 122 124 183

18 2.4. LOOK Scheduling SCAN (C-SCAN) moves the head across the full width of the disk. LOOK (C-LOOK) moves the head only as far as the last request in each direction, and then reverses (wraps around).

19 C-LOOK Example Fig. 13.5, p.437 Queue: 98, 183, 37, 122, 14, 124, 65, 67 Head starts at cylinder 53, and moving right. 14 37 53 65 67 98 122 124 183

20 2.5. Which Disk Scheduling Algorithm?
SSTF - commonly used SCAN/C-SCAN good for heavily loaded disks since they avoid starvation Choice depends on number/type of requests e.g. file I/O will generate sequences of requests to adjacent blocks continued

21 Caching? Comparisons can utilise seek distances (as here) and disk rotational latency. Logical addresses hide useful physical information (e.g. sector and track positions), that an OS-level scheduler could use. continued

22 There may be conflict between the OS and disk controller scheduling policies:
e.g. the OS may want disk writes to happen immediately and in a fixed order when a transaction is being carried out

23 3. Disk Formatting The disk controller uses low-level formatting (physical formatting) a data structure per each sector consists of header, data area (512 bytes), trailer utilises an error-correcting code (ECC) continued

24 The OS adds its own data structures:
partitions the disk into groups of cylinders logical formatting (make the file system) includes the directory/file structure, and lists of free and allocated pages

25 data blocks (subdirectories)
4. Boot Blocks Most book blocks hold a simple bootstrap loader whose only job is to load and execute a fuller bootstrap program from disk the program is located in a fixed place on disk (a boot partition) sector 0 book block sector 1 FAT root directory data blocks (subdirectories) MS-DOS

26 Bad Blocks A bad block is a defective sector.
The OS can mark bad blocks and then skip them, or maintain a list of bad blocks. Sector sparing (forwarding) substitute a (close) good block for the bad one Sector slipping move related blocks to be contiguous if they contain a bad block

27 5. Swap space Management Swap space algorithms use virtual memory (VM)
disk space treated as RAM slow management aim is to speed-up VM throughput

28 Swap Space Implementation
As a file: standard interface easy to implement inefficient use of physical memory As a special partition: no need to impose directory/file structures faster hard to reconfigure

29 5.1. UNIX Swap Space (4.3 BSD) Each process is assigned a swap space which holds: text segments (for pages of the program) data segments (for runtime data) The kernel uses two swap maps to track swap space usage in a process.

30 Swap Maps Figs. 13.7 and 13.8, p.444 text segment swap map 512K 512K
data segment swap map 16K 32K 64K 128K

31 6. Disk Reliability Common approach is to use multiple disks.
Disk stripping (interleaving) store data spread across several disks reduces chance of complete failure I/O data transfers can use parallelism continued

32 RAID (Redundant Array of Independent Disks)
Mirroring (shadowing) duplicates data across disks costly parallelism can increase speed Block interleaved parity if data on one machine is corrupted, it can be recalculated from the remaining data and parity information stored on the other machines


Download ppt "13. Secondary Storage (S&G, Ch. 13)"

Similar presentations


Ads by Google