The document provides an overview of I/O systems. It discusses peripheral devices and their I/O management through various techniques like direct memory access, polling, interrupts and buffering. It also covers topics like clocks and timers, caching, spooling, error handling, power management, kernel data structures and improving I/O performance through techniques such as reducing interrupts and using direct memory access. The document contains information presented through multiple sections on different I/O related concepts and components.
3. OVERVIEW
• The control of devices connected to the computer is
the major concern of operating system designer,
because I/O devices vary so widely in their functions
and speed.
• Varies methods are needed to control them.
3
5. Peripheral Devices
What Does Peripheral Device Mean?
• A Peripheral Device is an internal or external device that connects
directly to a computer or other digital device but does not contribute to
the computer's primary function, such as computing. It helps end users
access and use the functionalities of a computer.
• Since it’s not a core device for the system, the computer can still function
without the peripheral, which simply provides extra functions. However,
some peripherals such as a mouse, keyboard, or monitor tend to be
pretty much fundamental to the interaction between the user and the
computer itself.
5
6. Peripheral Devices
• A Peripheral Device is also called a computer
peripheral, input-output device, or I/O device.
• Peripheral Devices are connected with CPU by busses,
processor is not connected to these devices directly
rather it is connected by interface.
6
7. Peripheral Devices
• Why we use interface between peripheral devices and
processor ?
• Because CPU can execute millions of instruction per second, but
peripheral devices are slow e.g keyboard.
• If we connect them directly these devices cannot cope with the CPU
speed either CPU has to wait, or these devices cannot process the
data.
• So that's why interfaces are used to synchronous them properly.
• Interfaces contain multiple registers they pick data serially and send
to CPU in a parallel way by faster speed.
7
8. Peripheral Devices
• Different nature of devices (signals) and the role of
interface ?
• CPU (electrical device) KEYBOARD (electromechanical device)
magnetic disk (electro - magnetic).
• We use interface between them for signal conversion because
signals produced by these devices are of different nature.
• Also we use interface between them to equalize their format size.
8
9. Peripheral Devices
• All Peripheral Devices are of
different nature . if we want
to take data from them then
we have to built logic for
them separately.
• So, in order to avoid these
issues we use interface
between them.
9
Processor
Interface Interface Interface
Keyboard
and display
terminal
Printer
Magnetic
disk
Data
Address
Control
10. Block & Character Devices
• Block devices is one with which driver communicate by
sending blocks of data. for example, hard disk, usd camera
etc.
• Character devices: a character devices is one with which
the driver communicates by sending and receiving single
characters.
• For example: serial ports, sound cards etc.
10
11. I/O MANAGEMENT
• Synchronous I/O: in this scheme CPU execution waits while I/o
proceeds.
• Asynchronous I/O: in this scheme I/o proceeds concurrently with
CPU execution.
• The CPU must have a way to pass information to and from an I/O
devices. There is a way to communicate with CPU and I/O
devices.
1. Direct Memory Access
11
12. Direct Memory Access
• Direct Memory Access: DMA takes care
of entire data transfer. What is DMA?
• It is simply the transfer of data from one
resource to another resources without
involving CPU( You will ask why without
CPU because CPU does the entire job)
it is just to speed up the memory
operations.
12
CPU
Memory
Data
I/O Device
Data
I/O Commands
14. Direct Memory Access
• A DMA controller transfers 16-bit words to memory using cycle
stealing. The words are assembled from a device that transmit
characters at a rate of 2400 characters/sec. The CPU fetching
instructions at an average rate of 1million instructions)sec.
• By how much will the CPU be slowed down because of DMA
transfer?( Each character is of 8 bits).
Options
1. 12%
2. 0.12%
3. 24 %
4. 0.24 %
14
15. Polling & Interrupt I/O
• A computer must have a way of detecting the arrival of any type of
input. there are two ways that this can happen, known as polling and
interrupts.
• Polling I/O: Polling is the simplest way for an I/O device to communicate
with the processor. the process of periodically checking status of the
device to see if it is time for the next I/o operation, is called polling.
• Interrupt I/O: it is an alternative scheme for dealing with I/O called
interrupt driven method.
• An interrupt is the signal to the microprocessor from a device that
require attention.
15
16. Network Devices
• Computer networking devices, are electronic devices which are
required for communication and interaction between devices on a
computer network.
e.g hub , repeater, bridge etc.
• When referring to a network, a hub is the most basic networking
device that connects multiple computers or other network devices.
it operate on physical layer of OSI-model.
• The three types are active, passive and intelligent hub.
16
17. Network Devices
• Repeater as a networking device: A repeater is an
electronic device that amplifies the signal it receives.
• You can think of repeater as a device which receives a
signal and retransmits it at a higher level or higher power
so that the signal can cover longer distances.
• A bridge is a type of computer network device that
provides interconnection with other bridge networks that
use the same protocol. Bridge devices work at the data
link layer of the Open System Interconnect (OSI) model,
connecting two different networks together and providing
communication between them.
17
19. Clocks & Timers
Most computers clocks and timers that
provide three basic Functions:
• Give the current time.
• Give the elapsed time. (up time)
• Set a timer to trigger operation X at
time T.
19
20. Clocks & Timers
• Types of clocks
20
Hardware clock System clock
Kernel
Clock
RTC
21. Clocks & Timers
Hardware clock
• A real time clock (RTC) is a battery powered
clock that is integrated on a computer
motherboard as an IC.
• Lithium battery is used for back up power.
• It tracks the time even while the system is
turned off or is in a low power state.
• RTC is indirectly responsible for interrupts,
timer, task scheduling and synchronization
etc.
21
22. Clocks & Timers
System clock
• System Clock is Implemented or maintained in the
operating system and is used to set the tasks and
processes.
• System clock tracks the time after the system is
turned on.
• Used for:
• Synchronization and scheduling.
• Settings and managing interrupts.
• Setting timer. For Example Alarm.
22
25. Buffering
• Buffering is the process of preloading data into a buffer.
• What is a buffer? Where is it located?
• hardware devices or program processes that operate at
different speeds or with different sets of priorities. The
buffer allows each device or process to operate without
being held up by the other.
• It helps in Matching Speed between two devices,
between which the data is transmitted.
• It helps the devices with different data transfer size to
get adapted to each other.
25
26. Buffering Example
• Example of a YouTube video:
• When you are watching a YouTube video the
video has to preload some data before you can
watch it in real time.
• The data is stored in the buffer temporarily.
• CPU has to wait till the specified amount of data
is stored in the buffer.
• Then CPU executes the data in the buffer.
26
Buffer
Data
CPU
27. Buffering
• Types of Buffer:
• Single Buffer
• Double Buffer
27
Buffer 1
Buffer 2
Consumer
I/O DEVICE
Operating System
MOVE
User Process
Buffer 1 Consumer
I/O DEVICE
Operating System
MOVE
User Process
28. Buffering
• Types of Buffer:
• Single Buffer
• Double Buffer
• The usage of multiple buffers
increases the overall throughput
of a device and helps prevents
bottlenecks.
• A major disadvantage of double
buffering is that the complexity
of the process gets increased.
28
Data Flow
29. Caching
• What is Cache? Where is it located ?
• A cache is a high-speed memory that
temporarily saves data.
• Caching is a process of storing copies
of files in the cache memory.
• Caching is used to increase the
accessibility speed of the frequently
used programs on your system.
• Example of google chrome or loading
any application.
29
CPU
Main
Memory
Cache
Memory
30. Caching Example
• Whenever the CPU needs to access memory,
it first checks the cache memory. If the data
is not found in cache memory, then the CPU
moves into the main memory.
Advantage:
• Performance in increased by a lot.
• Results in better User Experience.
30
Index Data
0 Xyz
1 pdq
2 abc
3 rgf
Index Data
0 abc
1 xyz
Main Memory Cache Memory
CPU
31. Spooling
• Spooling is a process in which data is
temporarily held to be used and executed by a
device, program or the system.
• I/P and O/P devices are very slow as
compared to the CPU.
• Batch Operation.
• CPU is not set free in batch operation, it has to
wait for the I/O operation to be completed.
• To fix this we can use a Spool Buffer.
• This makes CPU utilization better.
• Multiple I/O devices can be used.
31
(Simultaneous Peripheral operations online)
Input Devices Output Devices
CPU
System
Main
Memory
Disk
Secondary
Memory
32. Spooling Example
32
• The biggest example of Spooling is printing. The documents
which are to be printed are stored in the SPOOL and then
added to the queue for printing.
• Many processes can perform their operations while the printer
executes the printing process on the documents one-by-one.
• Many features can also be added like setting priorities or
notification when the printing process has been completed or
selecting the different types of paper to print on according to
the user's choice.
33. Nonblocking & Asynchronous
33
• It refers to the program that does not block the execution of
further operations. Non-Blocking methods are executed
asynchronously.
• Asynchronously means that the program may not necessarily
execute line by line. The program calls the function and move
to the next operation and does not wait for it to return.
• Async is multi-thread, which means operations or programs
can run in parallel. Sync is single-thread, so only one
operation or program will run at a time.
34. Error Handling
• Error handling is defined as the ability of a software application
to help user to solve those problems that may occur while
using the application.
• Unexpected events
• Software tries to help the user giving error Messages.
• System error logs hold problem reports.
• The routines in a program that respond to abnormal input or
conditions.
• The quality of such routines is based on the clarity of the error
messages and the options given to users for resolving the
problem.
34
35. Error Handling
Types of errors that can occur:
• Syntax errors.
• Logic errors.
• The program can run but does not do what it is expected to
do.
• Usually called bugs.
• Runtime errors.
• Usually crashes the program.
35
37. I/O Protection
• User process may accidentally or
purposefully attempt to disrupt
normal operation via illegal I/O
instructions
• All I/O instructions defined to be
privileged
• I/O must be performed via system calls
• Memory-mapped and I/O port memory
locations must be protected too
37
39. Kernel Data Structures
• Kernel keep state info for I/O components using
open file tables and also track network
connections, character-device communications,
and other I/O activities.
• Some use object-oriented methods and message
passing to implement I/O.
• Windows uses message passing
• Message with I/O information passed from user
mode into kernel
• Message modified as it flows through to device
driver and back to process
39
40. Power Management
• Not strictly domain of I/O, but much is I/O related
• Computers and devices use electricity, generate heat,
frequently require cooling.
• OSes can help manage and improve use
• Cloud computing environments move virtual machines
between servers.
• Can end up evacuating whole systems and shutting them
down.
• Mobile computing has power management as first
class OS aspect.
40
41. Power Management
• For example, Android implements
• Component-level power management
• Understands relationship between components
• Build device tree representing physical device topology
• System bus -> I/O subsystem -> {flash, USB storage}
• Device driver tracks state of device, whether in use
• Unused component – turn it off
• All devices in tree branch unused – turn off branch
41
42. Power Management
• For example, Android implements
• Wake locks – like other locks but prevent sleep of device when lock is held.
• Power collapse – put a device into very deep sleep
• Marginal power use
• Only awake enough to respond to external stimuli (button press,
incoming call)
• Modern systems use advanced configuration and power interface (ACPI) who
provides an open standard that operating systems can use to discover and
configure computer hardware components, to perform power management,
auto configuration and status monitoring.
42
44. • STREAM – a full-duplex communication channel between a
user-level process and a device in Unix System V and beyond
• A STREAM consists of:
• STREAM head interfaces with the user process
• Driver end interfaces with the device
• Zero or more STREAM modules between them
• Each module contains a read queue and a write queue
• Message passing is used to communicate between queues
• Flow control option to indicate available or busy
• Asynchronous internally, synchronous where user process
communicates with stream head
44
STREAMS
46. • I/O a major factor in system
Performance:
• Demands CPU to execute device driver,
kernel I/O code
• Context switches due to interrupts
• Network traffic especially stressful
46
Performance
47. • Use DMAC.
• Reduce number of context switches.
• Reduce interrupts by using large transfers, smart
controllers, polling.
• Use smarter hardware devices.
• Balance CPU, memory, bus, and I/O performance
for highest throughput.
• Move user-mode processes / daemons to kernel
threads.
47
Improving Performance