Synchronization Andy Wang Operating Systems COP 4610 / CGS 5765.
Device Management Mark Stanovich Operating Systems COP 4610.
-
Upload
bernadette-williams -
Category
Documents
-
view
218 -
download
0
description
Transcript of Device Management Mark Stanovich Operating Systems COP 4610.
![Page 1: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/1.jpg)
Device Management
Mark StanovichOperating Systems
COP 4610
![Page 2: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/2.jpg)
So far…
We have covered CPU and memory management
Computing is not interesting without I/OsDevice management: the OS
component that manages hardware devicesProvides a uniform interface to access devices
with different physical characteristicsOptimizes the performance of individual
devices
![Page 3: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/3.jpg)
Basics of I/O Devices
Three categoriesA block device stores information in fixed-size
blocks, each one with its own addresse.g., disks
A character device delivers or accepts a stream of characters, and individual characters are not addressablee.g., keyboards, printers
A network device transmit data packets
![Page 4: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/4.jpg)
Device Controller
Bridge between device and CPU
Performs error correction if necessaryComponents:
Device registers to communicate with the CPUData buffer that an OS can read or write
![Page 5: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/5.jpg)
Device Driver
An OS component that is responsible for hiding the complexity of an I/O device
So that the OS can access various devices in a uniform manner
![Page 6: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/6.jpg)
Device Driver Illustrated
User applicationsVarious OS components
Device drivers
Device controllers
I/O devices
User level
OS level
Hardware level
![Page 7: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/7.jpg)
Device Addressing
Two approachesDedicated range of device addresses in the
physical memoryRequires special hardware instructions associated
with individual devicesMemory-mapped I/O: makes no distinction
between device addresses and memory addressesDevices can be access the same way as normal
memory, with the same set of hardware instructions
![Page 8: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/8.jpg)
Device Addressing Illustrated
Primarymemory
Device 1
Device 2
Memoryaddresses
Memory-mapped I/Os
Primary memory
Deviceaddresses
Separate deviceaddresses
![Page 9: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/9.jpg)
Ways to Access a Device
Polling: a CPU repeatedly checks the status of a device for exchanging data+ Simple- Busy-waiting
![Page 10: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/10.jpg)
Ways to Access a Device
Interrupt-driven I/Os: A device controller notifies the corresponding device driver when the device is available+ More efficient use of CPU cycles- May interrupt too often and unnecessarily
![Page 11: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/11.jpg)
Ways to Access a Device
Direct memory access (DMA): uses an additional controller to perform data movements+ CPU is not involved in copying data- A process cannot access in-transit data
![Page 12: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/12.jpg)
Ways to Access a Device
Double buffering: uses two buffers. While one is being used, the other is being filledAnalogy: pipeliningExtensively used for graphics and animation
So a viewer does not see the line-by-line scanning
![Page 13: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/13.jpg)
Overlapped I/O and CPU Processing
Process A (infinite loop)67% CPU33% I/O
Process B (infinite loop)33% CPU67% I/O
SRTFCPUI/O
B
B Time
B
B
B
B
A
A Time
A
A
A
A
B
B Time
B
B
B
B
A
A
A
A
A
A
![Page 14: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/14.jpg)
Disk as An Example Device
40-year-old storage technologyIncredibly complicatedA modern drive
250,000 lines of micro code
![Page 15: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/15.jpg)
Disk Characteristics
Disk platters: coated with magnetic materials for recording
Disk platters
![Page 16: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/16.jpg)
Disk Characteristics
Disk arm: moves a comb of disk headsOnly one disk head is active for reading/writing
Disk platters
Disk arm
Disk heads
![Page 17: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/17.jpg)
Hard Disk Trivia…
Aerodynamically designed to flyAs close to the surface as possibleNeed to minimize variations due to humidity,
temperature, etc.Therefore, hard drives are filled with
special inert gas If head touches the surface
Head crashScrapes off magnetic information
![Page 18: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/18.jpg)
Disk Characteristics
Each disk platter is divided into concentric tracks
Disk platters
Disk arm
Disk heads
Track
![Page 19: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/19.jpg)
Disk Characteristics
A track is further divided into sectors. A sector is the smallest unit of disk storage
Disk platters
Disk arm
Disk heads
Track
Sector
![Page 20: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/20.jpg)
Disk Characteristics
A cylinder consists of all tracks with a given disk arm position
Disk platters
Disk arm
Disk heads
Track
Sector
Cylinder
![Page 21: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/21.jpg)
Disk Characteristics
Cylinders are further divided into zones
Disk platters
Disk arm
Disk heads
Track
Sector
Cylinder
Zones
![Page 22: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/22.jpg)
Disk Characteristics
Zone-bit recording: zones near the edge of a disk store more information (higher bandwidth)
Disk platters
Disk arm
Disk heads
Track
Sector
Cylinder
Zones
![Page 23: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/23.jpg)
More About Hard Drives Than You Ever Want to KnowTrack skew: starting position of each track is
slightly skewedMinimize rotational delay when sequentially transferring
bytes across tracksThermo-calibrations: periodically performed to
account for changes of disk radius due to temperature changes
Typically 100 to 1,000 bits are inserted between sectors to account for minor inaccuracies
![Page 24: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/24.jpg)
Disk Access Time
Seek time: the time to position disk heads (~4 msec on average)
Rotational latency: the time to rotate the target sector to underneath the headAssume 7,200 rotations per minute (RPM)7,200 / 60 = 120 rotations per second1/120 = ~8 msec per rotationAverage rotational delay is ~4 msec
![Page 25: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/25.jpg)
Disk Access Time
Transfer time: the time to transfer bytesAssumptions:
58 Mbytes/sec4-Kbyte disk blocks
Time to transfer a block takes 0.07 msec
Disk access time Seek time + rotational delay + transfer time
![Page 26: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/26.jpg)
Disk Performance Metrics
Latency Seek time + rotational delay
BandwidthBytes transferred / disk access time
![Page 27: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/27.jpg)
Examples of Disk Access Times
If disk blocks are randomly accessedAverage disk access time = ~8 msecAssume 4-Kbyte blocks4 Kbyte / 8 msec = ~500 Kbyte/sec
If disk blocks of the same cylinder are randomly accessed without disk seeksAverage disk access time = ~4 msec4 Kbyte / 4 msec = ~ 1 Mbyte/sec
![Page 28: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/28.jpg)
Examples of Disk Access Times
If disk blocks are accessed sequentiallyWithout seeks and rotational delaysBandwidth: 58 Mbytes/sec
Key to good disk performanceMinimize seek time and rotational latency
![Page 29: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/29.jpg)
Disk Controller
Few popular standardsIDE (integrated device electronics)ATA (advanced technology attachment
interface)SCSI (small computer systems interface)SATA (serial ATA)
DifferencesPerformanceParallelism
![Page 30: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/30.jpg)
Disk Device Driver
Major goal: reduce seek time for disk accessesSchedule disk request to minimize disk arm
movements
![Page 31: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/31.jpg)
Disk Arm Scheduling Policies
First come, first serve (FCFS): requests are served in the order of arrival+ Fair among requesters- Poor for accesses to random disk blocks
Shortest seek time first (SSTF): picks the request that is closest to the current disk arm position+ Good at reducing seeks- May result in starvation
![Page 32: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/32.jpg)
Disk Arm Scheduling Policies
SCAN: takes the closest request in the direction of travel (an example of elevator algorithm)+ no starvation- a new request can wait for almost two full scans of the disk
![Page 33: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/33.jpg)
Disk Arm Scheduling Policies
Circular SCAN (C-SCAN): disk arm always serves requests by scanning in one direction. Once the arm finishes scanning for one
directionReturns to the 0th track for the next round of
scanning
![Page 34: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/34.jpg)
First Come, First Serve
Request queue: 3, 6, 1, 0, 7Head start position: 2
Tracks
0
5
4
3
2
1
6
7
Time
![Page 35: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/35.jpg)
First Come, First Serve
Request queue: 3, 6, 1, 0, 7Head start position: 2Total seek distance: 1 + 3 + 5 + 1 + 7 =
17
Tracks
0
5
4
3
2
1
6
7
Time
![Page 36: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/36.jpg)
Shortest Seek Distance First
Request queue: 3, 6, 1, 0, 7Head start position: 2
Tracks
0
5
4
3
2
1
6
7
Time
![Page 37: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/37.jpg)
Shortest Seek Distance First
Request queue: 3, 6, 1, 0, 7Head start position: 2Total seek distance: 1 + 2 + 1 + 6 + 1 =
11
Tracks
0
5
4
3
2
1
6
7
Time
![Page 38: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/38.jpg)
SCAN
Request queue: 3, 6, 1, 0, 7Head start position: 2
Time
Tracks
0
5
4
3
2
1
6
7
![Page 39: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/39.jpg)
SCAN
Request queue: 3, 6, 1, 0, 7Head start position: 2Total seek distance: 1 + 1 + 3 + 3 + 1 = 9
Time
Tracks
0
5
4
3
2
1
6
7
![Page 40: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/40.jpg)
C-SCAN
Request queue: 3, 6, 1, 0, 7Head start position: 2
Time
Tracks
0
5
4
3
2
1
6
7
![Page 41: Device Management Mark Stanovich Operating Systems COP 4610.](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b947f8b9ab0599c2b9a/html5/thumbnails/41.jpg)
C-SCAN
Request queue: 3, 6, 1, 0, 7Head start position: 2Total seek distance: 1 + 3 + 1 + 7 + 1 =
13
Time
Tracks
0
5
4
3
2
1
6
7