2. Roadmap
– I/O Devices
– Organization of the I/O Function
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Raid
– Disk Cache
3. Categories of
I/O Devices
• Difficult area of OS design
– Difficult to develop a consistent solution due
to a wide variety of devices and applications
• Three Categories:
– Human readable
– Machine readable
– Communications
4. Human readable
• Devices used to communicate with the
user
• Printers and terminals
– Video display
– Keyboard
– Mouse etc
5. Machine readable
• Used to communicate with electronic
equipment
– Disk drives
– USB keys
– Sensors
– Controllers
– Actuators(electric motors, stepper motors)
6. Communication
• Used to communicate with remote
devices
– Digital line drivers(connect a CD player to an
amplified speaker system.)
– Modems
7. Differences in
I/O Devices
• Devices differ in a number of areas
– Data Rate
– Application
– Complexity of Control
– Unit of Transfer
– Data Representation
– Error Conditions
9. Application
– Disk used to store files requires file
management software
– Disk used to store virtual memory pages
needs special hardware and software to
support it
– Terminal used by system administrator may
have a higher priority
10. Complexity of control
• A printer requires a relatively simple
control interface.
• A disk is much more complex.
• This complexity is filtered to some extent
by the complexity of the I/O module that
controls the device.
11. Unit of transfer
• Data may be transferred as
– a stream of bytes or characters (e.g., terminal
I/O)
– or in larger blocks (e.g., disk I/O).
12. Data representation
• Different data encoding schemes are used
by different devices,
–including differences in character code and
parity conventions.
13. Error Conditions
• The nature of errors differ widely from one
device to another.
• Aspects include:
– the way in which they are reported,
– their consequences,
– the available range of responses
14. Roadmap
– I/O Devices
– Organization of the I/O Function
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Raid
– Disk Cache
– UNIX SVR4 I/O
– LINUX I/O
– Windows I/O
16. • In this mode the data transfer is initiated by the instructions written in a
computer program.
• An input instruction is required to store the data from the device to the CPU and
a store instruction is required to transfer the data from the CPU to the device.
• Data transfer through this mode requires constant monitoring of the peripheral
device by the CPU and also monitor the possibility of new transfer once the
transfer has been initiated.
• Thus CPU stays in a loop until the I/O device indicates that it is ready for data
transfer.
• Thus programmed I/O is a time consuming process that keeps the processor busy
needlessly and leads to wastage of the CPU cycles.
Programmed I/O
17. • This mode uses an interrupt facility and special commands to inform
the interface to issue the interrupt command when data becomes
available and interface is ready for the data transfer.
• In the meantime CPU keeps on executing other tasks and need not
check for the flag.
• When the flag is set, the interface is informed and an interrupt is
initiated.
• Its module is faster than programmed I/O module.
• The CPU cycles are not wasted as CPU continues with other work
during this time and hence this method is more efficient.
Interrupt-driven I/O
18. • DMA modules controls the exchange of data between main memory and I/O
module.
• The data transfer between a fast storage media such as magnetic disk and memory unit
is limited by the speed of the CPU.
• we can allow the peripherals directly communicate with each other using the memory
buses, removing the intervention of the CPU.
Direct Memory Access (DMA)
19. • This type of data transfer technique is known as DMA or direct memory access.
• During DMA the CPU is idle and it has no control over the memory buses. The DMA
controller takes over the buses to manage the transfer directly between the I/O devices
and the memory unit.
Direct Memory Access (DMA)
20. Evolution of the
I/O Function
1. Processor directly controls a peripheral
device
2. Controller or I/O module is added
– Processor uses programmed I/O without
interrupts
– Processor does not need to handle details of
external devices
21. Evolution of the
I/O Function
cont…
3. Controller or I/O module with interrupts
– Efficiency improves as processor does not
spend time waiting for an I/O operation to be
performed
4. Direct Memory Access
– Blocks of data are moved into memory
without involving the processor
– Processor involved at beginning and end only
22. Evolution of the
I/O Function
cont…
5. I/O module is a separate processor
– CPU directs the I/O processor to execute
an I/O program in main memory.
6. I/O processor
– I/O module has its own local memory
– Commonly used to control communications
with interactive terminals
23. Direct Memory Address
•
•
•
Processor delegates I/O operation to the DMA
module
• DMA module transfers data directly to or form memory
When complete DMA module sends an interrupt
signal to the processor.
For DMA to be implemented, processor has to share
its’ system bus with the DMA module. Therefore, the
DMA module must use the bus only when the
processor does not need it, or it must force the
processor to suspend operation temporarily.
25. DMA Configurations:
Integrated DMA & I/O
• This means that there is a path between the DMA module and
one or more I/O modules that does not include the system bus.
The DMA logic may actually be a part of an I/O module, or it may be
a separate module that controls one or more I/O modules.
27. Roadmap
– I/O Devices
– Organization of the I/O Function
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Raid
– Disk Cache
– UNIX SVR4 I/O
– LINUX I/O
– Windows I/O
28. Goals: Efficiency
• Most I/O devices extremely slow
compared to main memory
• Use of multiprogramming allows for some
processes to be waiting on I/O while
another process executes
• I/O cannot keep up with processor speed
– Swapping used to bring in ready processes
– But this is an I/O operation itself
29. Generality
• For simplicity and freedom from error it is
desirable to handle all I/O devices in a
uniform manner
• Hide most of the details of device I/O in
lower-level routines
• Difficult to completely generalize, but can
use a hierarchical modular design of I/O
functions
30. Hierarchical design
• A hierarchical philosophy leads to
organizing an OS into layers
• Each layer relies on the next lower layer to
perform more primitive functions
• It provides services to the next higher
layer.
• Changes in one layer should not require
changes in other layers
31. Model of I/O organization
• Local peripheral device
• Communications port
• Filesystems
32. Local peripheral device
• Logical I/O:
– Deals with the device as a logical
resource
– Concerned with managing general I/O
functions on behalf of user processes,
allowing them to deal with the device in
terms of a device identifier and simple
commands such as open, close, read,
write.
33. Local peripheral device
• Device I/O:
– Converts requested operations into
sequence of I/O instructions
• Scheduling and Control
– Performs actual queuing and control
operations
34. Communications Port
• Similar to previous but the logical
I/O module is replaced by a
communications architecture,
– This consist of a number of layers.
– An example is TCP/IP,
35. File System
• Directory management
– Concerned with user operations
affecting files
• File System
– Logical structure and operations
• Physical organisation]
– Converts logical names to physical
addresses
36. Roadmap
– I/O Devices
– Organization of the I/O Function
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Raid
– Disk Cache
– UNIX SVR4 I/O
– LINUX I/O
– Windows I/O
37. I/O Buffering
• The buffer is an area in the main
memory used to store or hold the
data temporarily. In other words, buffer
temporarily stores data transmitted from
one place to another, either between two
devices or an application. The act of storing
data temporarily in the buffer is
called buffering.
38. Uses of I/O Buffering :
1.It helps in matching speed between two
devices in which the data is transmitted.
For example, a hard disk has to store the file
received from the modem.
As we know, the transmission speed of a modem
is slow compared to the hard disk.
So bytes coming from the modem is accumulated
in the buffer space, and when all the bytes of a
file has arrived at the buffer, the entire data is
written to the hard disk in a single operation.
39. Uses of I/O Buffering :
2. It helps the devices with different sizes of data
transfer to get adapted to each other. It helps
devices to manipulate data before sending or
receiving it. In computer networking, the large
message is fragmented into small fragments and
sent over the network. The fragments are
accumulated in the buffer at the receiving end
and reassembled to form a complete large
message.
40. Types of I/O
• Block-oriented device
• Stream-oriented device
41. Block-oriented Device
• Information is stored in fixed sized blocks
• Transfers are made a block at a time
–Can reference data b block number
• Used for disks and USB keys
42. Stream-Oriented
Device
• Transfer information as a stream of bytes
• Used for terminals, printers,
communication ports, mouse and other
pointing devices, and most other devices
that are not secondary storage
43. I/O buffering schemes
• No buffering
• Single buffering
• Double buffering
• Circular buffering
44. No Buffer
• Without a buffer, the OS directly access
the device as and when it needs
46. Block Oriented Single Buffer
• System buffer takes the input.
• After taking the input, the block gets transferred
to the user space by the process and then the
process requests for another block.
• Two blocks works simultaneously, when one bloc
of data is processed by the user process, the next
block is being read in.
• OS can swap the processes.
• OS can record the data of system buffer to user
processes.
47. Stream Oriented Single Buffer
• Line- at a time operation is used for scroll made
terminals. User inputs one line at a time, with a
carriage return signaling at the end of a line.
48. Double Buffer
• Use two system buffers instead of one
• A process can transfer data to or from one
buffer while the operating system empties
or fills the other buffer
49. Circular Buffer
• More than two buffers are used
• Each individual buffer is one unit in a
circular buffer
• Used when I/O operation must keep up
with process
50. Roadmap
– I/O Devices
– Organization of the I/O Function
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Raid
– Disk Cache
– UNIX SVR4 I/O
– LINUX I/O
– Windows I/O
51. Disk Performance
Parameters
• The actual details of disk I/O operation
depend on many things
–A general timing diagram of disk I/O transfer
is shown here.
52. Positioning the
Read/Write Heads
• When the disk drive is operating, the disk
is rotating at constant speed.
• Track selection involves moving the head
in a movable-head system or electronically
selecting one head on a fixed-head system.
53. Disk Performance
Parameters
Seek Time:Seek time is the time taken to locate the disk arm to a
specified track where the data is to be read or write. So the disk
scheduling algorithm that gives minimum average seek time is
better.
Rotational Latency: Rotational Latency is the time taken by the
desired sector of disk to rotate into a position so that it can access
the read/write heads. So the disk scheduling algorithm that gives
minimum rotational latency is better.
Transfer Time: Transfer time is the time to transfer the data. It
depends on the rotating speed of the disk and number of bytes to
be transferred.
Disk Access Time: Disk Access Time is:
Disk Access Time = Seek Time + Rotational Latency + Transfer Time
54. Roadmap
– I/O Devices
– Organization of the I/O Function
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Raid
– Disk Cache
– UNIX SVR4 I/O
– LINUX I/O
– Windows I/O
55. RAID
• Redundant Array of Independent Disks
• RAID or redundant array of independent disks
is a data storage virtualization technology that
combines multiple physical disk drive
components into one or more logical units for
data redundancy, performance improvement,
or both.
56. RAID
Each of RAID levels has its own characteristics
of:
Fault-tolerance is the ability to survive one or
several disk failures.
Performance shows the change in the read and
writes speed of the entire array compared to a
single disk.
57. RAID 0 – Stripped-
RAID 0 is taking any number of disks and merging them into
one large volume. It will increase speeds as you're reading and
writing from multiple disks at a time. But all data on all disks is
lost if any one disk fails.
58. RAID 1 -Mirrored
• It duplicates data across two disks in the array,
providing full redundancy. Both disks are store exactly
the same data, at the same time, and at all times.
Data is not lost as long as one disk survives.
59. RAID 2
(Using Hamming code)
• In a parallel access array, all member disks participate in the execution of
every I/O request.
• Typically, the spindles of the individual drives are synchronized so that each disk
head is in the same position on each disk at any given time.
• Data stripping is used (extremely small)
• Hamming code used to correct single bit errors and detect double-bit errors.
• Not implemented in practice due to high costs and overheads.
60. RAID 3
bit-interleaved parity
•
•
•
– Instead of an error-correcting code, a simple parity bit is computed for the set of individual
bits in the same position on all of the data disks.
– In case of disk failure,the parity drive is accessed and data is reconstructed from the
remaining devices.
RAID 3 is organized in a similar fashion to RAID 2.
The difference is that RAID 3 requires only a single redundant disk, no matter how
large the disk array.
RAID 3 employs parallel access, with data distributed in small strips.
61. RAID 4
Block-level parity
• A bit-by-bit parity strip is calculated across corresponding strips on
each data disk.
• The parity bits are stored in the corresponding strip on the parity disk.
• Read performance is very good because of the blocks.
• Lowest overhead of check disks.
• Bottleneck
62. RAID 5
•
•
Block-level Distributed parity
RAID 5 is organized in a similar fashion to RAID 4.
RAID 5 distributes the parity strips across all disks.
• A typical allocation is a round-robin scheme
• For an n-disk array, the parity strip is on a different disk for the first n stripes, and the pattern
then repeats.
• The distribution of parity strips across all drives avoids the potential I/O bottleneck of
the single parity disk found in RAID 4.
63. RAID 6
Dual Redundancy
• Two different parity calculations are
carried out
–stored in separate blocks on different disks.
• Can recover from two disks failing