SlideShare a Scribd company logo
1 of 38
Device Management
So far…
We have covered CPU and memory
management
Computing is not interesting without I/Os
Device management: the OS component
that manages hardware devices
Provides a uniform interface to access devices
with different physical characteristics
Optimize the performance of individual devices
I/O hardware
 I/O device hardware
 Many varieties
 Device controller
Conversion a block of bytes and I/O operations
Performs error correction if necessary
Expose hardware registers to control the device
Typically have four registers:
• Data-in register to be read to get input
• Data-out register to be written to send output
• Status register (allows the status of the device to be
checked)
• Control register (controls the command the device
performs)
Device Addressing
 How the CPU addresses the device
registers?
 Two approaches
Dedicated range of device addresses in the
physical memory
Requires special hardware instructions associated with
individual devices
Memory-mapped I/O: makes no distinction
between device addresses and memory addresses
Devices can be accessed the same way as normal
memory, with the same set of hardware instructions
Device Addressing Illustrated
Primary
memory
Device 1
Device 2
Memory
addresses
Memory-mapped I/Os
Primary
memory
Device
addresses
Separate device
addresses
Ways to Access a Device
How to input and output data to and from
an I/O device?
Polling: a CPU repeatedly checks the
status of a device for exchanging data
+ Simple
- Busy-waiting
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
- Data copying and movements
- Slow for character devices (i.e., one interrupt
per keyboard input)
Ways to Access a Device
Direct memory access (DMA): uses an
additional controller to perform data
movements
+ CPU is not involved in copying data
- I/O device is much more complicated (need to
have the ability to access memory).
- A process cannot access in-transit data
Ways to Access a Device
Double buffering: uses two buffers.
While one is being used, the other is being
filled.
Analogy: pipelining
Extensively used for graphics and animation
So a viewer does not see the line-by-line scanning
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
Types of IO devices
 Two categories
 A block device stores information in fixed-size blocks, each
one with its own address
 e.g., disks
 A character device delivers or accepts a stream of
characters, and individual characters are not addressable
 e.g., keyboards, printers, network cards
 Device driver provides interface for these two types of
devices
 Other OS components see block devices and character
devices, but not the details of the devices.
 How to effectively utilize the device is the responsibility of the
device driver
Device Driver Illustrated
User applications
Various OS components
Device drivers
Device controllers
I/O devices
User level
OS level
Hardware level
Disk as An Example Device
30-year-old storage technology
Incredibly complicated
A modern drive
250,000 lines of micro code
Disk Characteristics
Disk platters: coated with magnetic
materials for recording
Disk
platters
Disk Characteristics
Disk arm: moves a comb of disk heads
Only one disk head is active for reading/writing
Disk
platters
Disk arm
Disk heads
Hard Disk Trivia…
Aerodynamically designed to fly
As close to the surface as possible
No room for air molecules
Therefore, hard drives are filled with
special inert gas
If head touches the surface
Head crash
Scrapes off magnetic information
Disk Characteristics
Each disk platter is divided into concentric
tracks
Disk
platters
Disk arm
Disk heads
Track
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
Disk Characteristics
A cylinder consists of all tracks with a
given disk arm position
Disk
platters
Disk arm
Disk heads
Track
Sector
Cylinder
Disk Characteristics
Cylinders are further divided into zones
Disk
platters
Disk arm
Disk heads
Track
Sector
Cylinder
Zones
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
More About Hard Drives Than You Ever
Want to Know
 Track skew: starting position of each track is
slightly skewed
Minimize rotational delay when sequentially transferring
bytes across tracks
 Thermo-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
Disk Access Time
Seek time: the time to position disk
heads (~8 msec on average)
Rotational latency: the time to rotate the
target sector to underneath the head
Assume 7,200 rotations per minute (RPM)
7,200 / 60 = 120 rotations per second
1/120 = ~8 msec per rotation
Average rotational delay is ~4 msec
Disk Access Time
Transfer time: the time to transfer bytes
Assumptions:
58 Mbytes/sec
4-Kbyte disk blocks
Time to transfer a block takes 0.07 msec
Disk access time
Seek time + rotational delay + transfer time
Disk Performance Metrics
Latency
Seek time + rotational delay
Bandwidth
Bytes transferred / disk access time
Examples of Disk Access Times
If disk blocks are randomly accessed
Average disk access time = ~12 msec
Assume 4-Kbyte blocks
4 Kbyte / 12 msec = ~340 Kbyte/sec
If disk blocks of the same cylinder are
randomly accessed without disk seeks
Average disk access time = ~4 msec
4 Kbyte / 4 msec = ~ 1 Mbyte/sec
Examples of Disk Access Times
If disk blocks are accessed sequentially
Without seeks and rotational delays
Bandwidth: 58 Mbytes/sec
Key to good disk performance
Minimize seek time and rotational latency
Disk Tradeoffs
Larger sector size  better bandwidth
Wasteful if only 1 byte out of 1 Mbyte is
needed
Sector size Space utilization Transfer rate
1 byte 8 bits/1008 bits (0.8%) 80 bytes/sec (1 byte / 12 msec)
4 Kbytes 4096 bytes/4221 bytes (97%) 340 Kbytes/sec (4 Kbytes / 12 msec)
1 Mbyte (~100%) 58 Mbytes/sec (peak bandwidth)
Disk Controller
Few popular standards
IDE (integrated device electronics)
ATA (AT attachment interface)
SCSI (small computer systems interface)
Differences
Performance
Parallelism
Disk Device Driver
Major goal: reduce seek time for disk
accesses
Schedule disk request to minimize disk arm
movements
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
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
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
direction
Returns to the 0th track for the next round of
scanning
First Come, First Serve
Request queue: 3, 6, 1, 0, 7
Head start position: 2
Total seek distance: 1 + 3 + 5 + 1 + 7 =
17
Tracks
0
5
4
3
2
1
6
7
Time
Shortest Seek Distance First
Request queue: 3, 6, 1, 0, 7
Head start position: 2
Total seek distance: 1 + 2 + 1 + 6 + 1 =
10
Tracks
0
5
4
3
2
1
6
7
Time
SCAN
Request queue: 3, 6, 1, 0, 7
Head start position: 2
Total seek distance: 1 + 1 + 3 + 3 + 1 = 9
Time
Tracks
0
5
4
3
2
1
6
7
C-SCAN
Request queue: 3, 6, 1, 0, 7
Head start position: 2
Total seek distance: 1 + 3 + 1 + 7 + 1 =
13
Time
Tracks
0
5
4
3
2
1
6
7
Look and C-Look
Similar to SCAN and C-SCAN
 the arm goes only as far as the final request in
each direction, then turns around
 Look for a request before continuing to move in a
given direction.

More Related Content

Similar to Lecture Notes for Device management in Operating Systems

Similar to Lecture Notes for Device management in Operating Systems (20)

Cs8493 unit 4
Cs8493 unit 4Cs8493 unit 4
Cs8493 unit 4
 
7 disk managment
7 disk managment7 disk managment
7 disk managment
 
CH10.pdf
CH10.pdfCH10.pdf
CH10.pdf
 
Viknesh
VikneshViknesh
Viknesh
 
Ch12
Ch12Ch12
Ch12
 
Pandi
PandiPandi
Pandi
 
Thiru
ThiruThiru
Thiru
 
Hard disk
Hard diskHard disk
Hard disk
 
Lecture 02 hardware
Lecture 02 hardwareLecture 02 hardware
Lecture 02 hardware
 
Mass Storage Structure
Mass Storage StructureMass Storage Structure
Mass Storage Structure
 
Os
OsOs
Os
 
Db
DbDb
Db
 
db
dbdb
db
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
Secondary storage structure-Operating System Concepts
Secondary storage structure-Operating System ConceptsSecondary storage structure-Operating System Concepts
Secondary storage structure-Operating System Concepts
 
Intro to computer fundamentals
Intro to computer fundamentalsIntro to computer fundamentals
Intro to computer fundamentals
 
I/O System and Csae Study
I/O System and Csae StudyI/O System and Csae Study
I/O System and Csae Study
 
Palpandi
PalpandiPalpandi
Palpandi
 
OSCh14
OSCh14OSCh14
OSCh14
 
OS_Ch14
OS_Ch14OS_Ch14
OS_Ch14
 

Recently uploaded

VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...Call Girls in Nagpur High Profile
 
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...Pooja Nehwal
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...Suhani Kapoor
 
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...Pooja Nehwal
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...nagunakhan
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Pooja Nehwal
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Pooja Nehwal
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样qaffana
 
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...Call Girls in Nagpur High Profile
 
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一ga6c6bdl
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝soniya singh
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsappssapnasaifi408
 

Recently uploaded (20)

Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565
 
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
 
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
 
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
 
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
 
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
 
9953330565 Low Rate Call Girls In Jahangirpuri Delhi NCR
9953330565 Low Rate Call Girls In Jahangirpuri  Delhi NCR9953330565 Low Rate Call Girls In Jahangirpuri  Delhi NCR
9953330565 Low Rate Call Girls In Jahangirpuri Delhi NCR
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
 

Lecture Notes for Device management in Operating Systems

  • 2. So far… We have covered CPU and memory management Computing is not interesting without I/Os Device management: the OS component that manages hardware devices Provides a uniform interface to access devices with different physical characteristics Optimize the performance of individual devices
  • 3. I/O hardware  I/O device hardware  Many varieties  Device controller Conversion a block of bytes and I/O operations Performs error correction if necessary Expose hardware registers to control the device Typically have four registers: • Data-in register to be read to get input • Data-out register to be written to send output • Status register (allows the status of the device to be checked) • Control register (controls the command the device performs)
  • 4. Device Addressing  How the CPU addresses the device registers?  Two approaches Dedicated range of device addresses in the physical memory Requires special hardware instructions associated with individual devices Memory-mapped I/O: makes no distinction between device addresses and memory addresses Devices can be accessed the same way as normal memory, with the same set of hardware instructions
  • 5. Device Addressing Illustrated Primary memory Device 1 Device 2 Memory addresses Memory-mapped I/Os Primary memory Device addresses Separate device addresses
  • 6. Ways to Access a Device How to input and output data to and from an I/O device? Polling: a CPU repeatedly checks the status of a device for exchanging data + Simple - Busy-waiting
  • 7. 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 - Data copying and movements - Slow for character devices (i.e., one interrupt per keyboard input)
  • 8. Ways to Access a Device Direct memory access (DMA): uses an additional controller to perform data movements + CPU is not involved in copying data - I/O device is much more complicated (need to have the ability to access memory). - A process cannot access in-transit data
  • 9. Ways to Access a Device Double buffering: uses two buffers. While one is being used, the other is being filled. Analogy: pipelining Extensively used for graphics and animation So a viewer does not see the line-by-line scanning
  • 10. 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
  • 11. Types of IO devices  Two categories  A block device stores information in fixed-size blocks, each one with its own address  e.g., disks  A character device delivers or accepts a stream of characters, and individual characters are not addressable  e.g., keyboards, printers, network cards  Device driver provides interface for these two types of devices  Other OS components see block devices and character devices, but not the details of the devices.  How to effectively utilize the device is the responsibility of the device driver
  • 12. Device Driver Illustrated User applications Various OS components Device drivers Device controllers I/O devices User level OS level Hardware level
  • 13. Disk as An Example Device 30-year-old storage technology Incredibly complicated A modern drive 250,000 lines of micro code
  • 14. Disk Characteristics Disk platters: coated with magnetic materials for recording Disk platters
  • 15. Disk Characteristics Disk arm: moves a comb of disk heads Only one disk head is active for reading/writing Disk platters Disk arm Disk heads
  • 16. Hard Disk Trivia… Aerodynamically designed to fly As close to the surface as possible No room for air molecules Therefore, hard drives are filled with special inert gas If head touches the surface Head crash Scrapes off magnetic information
  • 17. Disk Characteristics Each disk platter is divided into concentric tracks Disk platters Disk arm Disk heads Track
  • 18. 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
  • 19. Disk Characteristics A cylinder consists of all tracks with a given disk arm position Disk platters Disk arm Disk heads Track Sector Cylinder
  • 20. Disk Characteristics Cylinders are further divided into zones Disk platters Disk arm Disk heads Track Sector Cylinder Zones
  • 21. 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
  • 22. More About Hard Drives Than You Ever Want to Know  Track skew: starting position of each track is slightly skewed Minimize rotational delay when sequentially transferring bytes across tracks  Thermo-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
  • 23. Disk Access Time Seek time: the time to position disk heads (~8 msec on average) Rotational latency: the time to rotate the target sector to underneath the head Assume 7,200 rotations per minute (RPM) 7,200 / 60 = 120 rotations per second 1/120 = ~8 msec per rotation Average rotational delay is ~4 msec
  • 24. Disk Access Time Transfer time: the time to transfer bytes Assumptions: 58 Mbytes/sec 4-Kbyte disk blocks Time to transfer a block takes 0.07 msec Disk access time Seek time + rotational delay + transfer time
  • 25. Disk Performance Metrics Latency Seek time + rotational delay Bandwidth Bytes transferred / disk access time
  • 26. Examples of Disk Access Times If disk blocks are randomly accessed Average disk access time = ~12 msec Assume 4-Kbyte blocks 4 Kbyte / 12 msec = ~340 Kbyte/sec If disk blocks of the same cylinder are randomly accessed without disk seeks Average disk access time = ~4 msec 4 Kbyte / 4 msec = ~ 1 Mbyte/sec
  • 27. Examples of Disk Access Times If disk blocks are accessed sequentially Without seeks and rotational delays Bandwidth: 58 Mbytes/sec Key to good disk performance Minimize seek time and rotational latency
  • 28. Disk Tradeoffs Larger sector size  better bandwidth Wasteful if only 1 byte out of 1 Mbyte is needed Sector size Space utilization Transfer rate 1 byte 8 bits/1008 bits (0.8%) 80 bytes/sec (1 byte / 12 msec) 4 Kbytes 4096 bytes/4221 bytes (97%) 340 Kbytes/sec (4 Kbytes / 12 msec) 1 Mbyte (~100%) 58 Mbytes/sec (peak bandwidth)
  • 29. Disk Controller Few popular standards IDE (integrated device electronics) ATA (AT attachment interface) SCSI (small computer systems interface) Differences Performance Parallelism
  • 30. Disk Device Driver Major goal: reduce seek time for disk accesses Schedule disk request to minimize disk arm movements
  • 31. 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
  • 32. 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
  • 33. 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 direction Returns to the 0th track for the next round of scanning
  • 34. First Come, First Serve Request queue: 3, 6, 1, 0, 7 Head start position: 2 Total seek distance: 1 + 3 + 5 + 1 + 7 = 17 Tracks 0 5 4 3 2 1 6 7 Time
  • 35. Shortest Seek Distance First Request queue: 3, 6, 1, 0, 7 Head start position: 2 Total seek distance: 1 + 2 + 1 + 6 + 1 = 10 Tracks 0 5 4 3 2 1 6 7 Time
  • 36. SCAN Request queue: 3, 6, 1, 0, 7 Head start position: 2 Total seek distance: 1 + 1 + 3 + 3 + 1 = 9 Time Tracks 0 5 4 3 2 1 6 7
  • 37. C-SCAN Request queue: 3, 6, 1, 0, 7 Head start position: 2 Total seek distance: 1 + 3 + 1 + 7 + 1 = 13 Time Tracks 0 5 4 3 2 1 6 7
  • 38. Look and C-Look Similar to SCAN and C-SCAN  the arm goes only as far as the final request in each direction, then turns around  Look for a request before continuing to move in a given direction.