Presentation is loading. Please wait.

Presentation is loading. Please wait.

OSes: 13. Secondary Storage 1 Operating Systems v Objectives –introduce issues such as disk scheduling, formatting, and swap space management Certificate.

Similar presentations


Presentation on theme: "OSes: 13. Secondary Storage 1 Operating Systems v Objectives –introduce issues such as disk scheduling, formatting, and swap space management Certificate."— Presentation transcript:

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

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

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

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

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

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

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

8 OSes: 13. Secondary Storage 8 Types of Disk Scheduling v First-Come First-Served (FCFS) v Shortest Seek-Time First (SSTF) v SCAN (and C-SCAN) v LOOK (and C-LOOK)

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

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

11 OSes: 13. Secondary Storage SSTF Scheduling v The next request to be serviced is the one closest to the current head position –minimize seek time v Reduces overall head movement. v May lead to starvation for some requests.

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

13 OSes: 13. Secondary Storage 13 Not Optimal v 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 OSes: 13. Secondary Storage SCAN Scheduling v Scan back and forth across the disk –sometimes called the elevator algorithm v Problem: if a request arrives just behind the head then it will have to wait until the head returns.

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

16 OSes: 13. Secondary Storage 16 C-SCAN Scheduling v ‘C’ for “circular list”. v 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 OSes: 13. Secondary Storage 17 Example v Queue: 98, 183, 37, 122, 14, 124, 65, 67 v Head starts at cylinder 53, and moves right. Fig. 13.4, p

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

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

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

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

22 OSes: 13. Secondary Storage 22 v 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 OSes: 13. Secondary Storage Disk Formatting v The disk controller uses low-level formatting (physical formatting) –a data structure per each sector –consists of u header, data area (512 bytes), trailer –utilises an error-correcting code (ECC) continued

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

25 OSes: 13. Secondary Storage Boot Blocks v 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) book block FAT root directory data blocks (subdirectories) sector 0 sector 1 MS-DOS

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

27 OSes: 13. Secondary Storage Swap space Management v Swap space algorithms use virtual memory (VM) –disk space treated as RAM –slow –management aim is to speed-up VM throughput

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

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

30 OSes: 13. Secondary Storage 30 Swap Maps Figs and 13.8, p K 32K text segment swap map data segment swap map 16K32K64K128K

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

32 OSes: 13. Secondary Storage 32 v Mirroring (shadowing) duplicates data across disks –costly –parallelism can increase speed v 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 RAID (Redundant Array of Independent Disks)


Download ppt "OSes: 13. Secondary Storage 1 Operating Systems v Objectives –introduce issues such as disk scheduling, formatting, and swap space management Certificate."

Similar presentations


Ads by Google