Download presentation
Presentation is loading. Please wait.
1
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output – 5 Disks CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University Department of Computer Engineering
2
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 2 Disks have many types Magnetic disks Hard disk Floppy disk Optical disks CD-ROM CD-Writable CD-Recordable DVDs
3
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 3 Magnetic Disks Organized into cylinders Each cylinders contains tracks whose number is equal to the number of heads in the disk drive Each track is divided into a number of sectors: 8-32 sectors/track. The sector size is usually 512 bytes. There are IDE disks There are SCSI disks, etc.
4
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 4 A Hard Disk Disk Arm Arm motion path Disk Head One platter
5
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 5 One cylinder One track One sector
6
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 6 Disk Parameters ParameterWD 18300 Hard Disk Number of cyclinders10601 Tracks per cyclinder12 Sectors per track281 (average) Sectors per disk35742000 Bytes per sector512 Disk capacity18.3 GB Seek time (adjacent cylinders)0.8 msec Seek time (average case)6.9 msec Rotation time8.33 msec Motor stop/start time20 sec Time to transfer 1 sector 17 sec
7
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 7 Physical Geometry 0 1 2 3 4 5 6 7 8 9 10 1112 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 6 7 8 9 10 1112 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 56 7 8 9 10 11 Two zones DiskOne zone Disk
8
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 8 Disk Formatting After manufacturing, there is no information on the disk Just empty bits. Each platter need to have A low-level format A high-level format before disk can be used.
9
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 9 Disk Formatting Each track should have formatted in the following way: Sectors and inter-sector-gap between them A sector will be have format like the following: Preable – data (512 bytes) – Checksum sector preambleData (512 bytes)ECC (~16 bytes) -certain bit pattern - cylinder number -sector number
10
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 10 Cylinder Skew 0 1 2 3 4 5 6 7 8 9 10 1112 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 6 79 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1617 18 19 20 21 22 23 Direction of rotation Sweep path > time to change track (cyclinder)
11
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 11 Interleaving 0 1 2 3 4 5 6 79 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1617 18 19 20 21 22 23 registers CPU MEMORY Disk Controller 1 sector buffer (1) (2) (3)
12
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 12 Interleaving If we have ONE sector buffer in the disk controller: After we have transferred one sector of data from hard-disk ton controller buffer: We will copy the controller buffer to the memory This may take time. During this time, the disk-head will pass the start of the next sector. Therefore, the next logical sector, should not be the next physical sector in hard-disk. There should be some interleaving.
13
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 13 Interleaving 1 2 3 5 4 6 70 4 1 5 6 2 3 70 3 6 1 7 4 2 50 Non-interleaving Single Interleaving Double Interleaving
14
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 14 Disk Arm Scheduling How long does it take to read a block (sector) Seek time Move arm to the correct cyclinder Rotational delay Wait until correct sector comes under head. Actual data transfer time For most systems, the seek time dominates the other two times.
15
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 15 Disk Arm Scheduling Assume the disk is heavily loaded. There are a lot requests for disk blocks that are arriving to the hard disk driver. The drivers queues the requests. The driver knows for each block request, where in hard disk the block should be stored (the cylinder number). Since moving between cylinders (seek time) is costly, we should try to minimize these seek times.
16
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 16 Disk Arm Scheduling Disk driver Keeps a table of requests. Table is indexed by the cylinder number Blocks Requests for the same cylinder are put in a linked list. xxxxx 05101520 Initial position pending requests cylinder number
17
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 17 Disk Arm Scheduling Algorithms Several Algorithms Exist First Come First Served (FCFS) Shortest Seek First (SSF) Elevator Algorithm
18
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 18 FCFS Serve the request in the order they arrive (don’t look to the cylinder numbers) Example: Assume the current position is cylinder 11. The following requests arrive in the given time order: 1, 36, 16, 34, 9, 12 The request will be served in the same order. The head will go to: Cylinder 1 first (10 cylinder motion) Cylinder 36 next (35 cylinder motion) Cylinder 16 next (20) Cylinder 34 next (18) Cylinder 9 next (25) Cylinder 12 next (3) Total of 111 cylinders are skipped. Cost = 111
19
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 19 FCFS xxxxx xx 051015 20253035 New request arrival sequence: 1, 36, 16, 34, 9, 12 Initial head position
20
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 20 Shortest Seek First Satisfy the request that need shortest seek from the current position. In the previous example, this algorithms moved the head to cylinders in the order given below. 12, 9, 16, 1, 34, and 36. Moving the head to these cylinders require: 1, 3, 7, 15, 33, and 2 arm motions (that many cylinders are skipped at every request). Total cost = 61.
21
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 21 SSF xxxxx xx 051015 20253035 New request arrival sequence: 1, 36, 16, 34, 9, 12 Initial head position
22
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 22 Elevator Algorithm Do like what an elevator does. 1. Move in one direction until all request in that direction is served 2. Then change direction. 3. Move in the new direction until all request in that direction are server. Repeat steps 1, 2, and 3. In the previous example Assume initial position was 11 and initial direction was up (going to higher numbered cylinders).
23
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 23 Elevator Algorithm xxxxx xx 051015 20253035 New request arrival sequence: 1, 36, 16, 34, 9, 12 Initial head position
24
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 24 Elevator Algorithm The request are server in the following order: 12, 16, 34, 36, 9, 1 Arm motions (# of cylinder skips) 1, 4, 18, 2, 27, 8 Total cost = 60 cylinders. Performs good and is fair.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.