SlideShare a Scribd company logo
1 of 57
Download to read offline
P.C.P Bhatt OS/M5/V1/2004 1
Input Output (IO) Management
Prof. P.C.P. Bhatt
P.C.P Bhatt OS/M5/V1/2004 2
• Humans interact with machines by providing
information through IO devices.
• Many on-line services are availed through use of
specialized devices like printers, keyboards etc.
• Management of these devices can affect the throughput
of a system.
Introduction
P.C.P Bhatt OS/M5/V1/2004 3
Communication with an IO device is required at the
following levels:
¾ The need for a human to input information and
output from a computer.
¾ The need for a device to input information and
receive output from a computer.
¾ The need for computers to communicate over
networks.
Issues in IO Management
P.C.P Bhatt OS/M5/V1/2004 4
¾Character oriented input devices operate with
speeds of tens of bytes per second.
¾Block oriented devices are much faster than
character oriented devices. Also note that they
operate over a much wider range.
Devices communicate bit or byte streams with a
machine using a data bus and a device controller.
Device Speeds
P.C.P Bhatt OS/M5/V1/2004 5
• A computer system may have to synchronize with
some other process to communicate.
• So, one process may actually wait at the point of
rendezvous for the other process to arrive.
• The process advances further following the
synchronizing event.
Event Based I/O -1
P.C.P Bhatt OS/M5/V1/2004 6
• Processes may use signals to communicate events.
• Processes may wait for asynchronous events to occur.
• Every OS provides a set of mechanisms which may be
like polling, or a programmed data transfer, or an interrupt
mechanism, or even use DMA with cycle stealing.
Event Based I/O -2
P.C.P Bhatt OS/M5/V1/2004 7
IO Organization -1
Computers employ the four basic modes of IO operation:
These are:
1. Polling
2. Programmed mode
3. Interrupt mode
4. DMA mode
P.C.P Bhatt OS/M5/V1/2004 8
Polling
• Polling: Computer interrogates each device in turn to
determine if it is ready to communicate.
• Polling as a strategy is also used by systems to interrogate
ports on a computer communication network.
P.C.P Bhatt OS/M5/V1/2004 9
9 Programmed mode :
An IO instruction is issued to a device.
Now the program busy-waits (idles) till the device IO
is completed.
In other words execution of I/O instruction is in
sequence with other program instructions.
Programmed mode
P.C.P Bhatt OS/M5/V1/2004 10
9 Interrupt mode :
An IO instruction is issued.
The program advances without suspension till the
device is actually ready to establish an IO, when the
process is suspended.
Interrupt mode
P.C.P Bhatt OS/M5/V1/2004 11
9 DMA mode :
The device requests for an IO for a block data transfer.
The execution is briefly suspended and the starting
address and size of data block are stored in a DMA
controller.
DMA mode
P.C.P Bhatt OS/M5/V1/2004 12
9 Programmed IO is used for synchronizing information
or when speed is not critical, e.g. – in the i386 CPU
based PC architecture, there is a notion of listening to
an IO port.
9 Interrupt transfer is suited for a small amount of critical
information – no more than tens of bytes.
9 DMA is used mostly for block devices.
IO Modes: some observations
P.C.P Bhatt OS/M5/V1/2004 13
Direct Memory Access Mode
of Data Transfer
P.C.P Bhatt OS/M5/V1/2004 14
Network oriented traffic can be handled in DMA mode.
Network traffic usually corresponds to getting
information from a disc file at both ends and network
traffic is bursty.
In all the above modes, OS makes it look as if we are
doing a read or a write operation on a file.
Network oriented traffic
P.C.P Bhatt OS/M5/V1/2004 15
In this mode, an IO instruction is issued and the program
advances without suspension.
Program suspension happens when the device is actually
ready to establish an IO.
An Interrupt Service Routine is executed to achieve
device IO.
Interrupt Mode - 1
P.C.P Bhatt OS/M5/V1/2004 16
Process context is stored to help resume computation
later (from the point of suspension.)
Program resumes execution from where it
was suspended.
Interrupt Mode - 2
P.C.P Bhatt OS/M5/V1/2004 17
Interrupt processing may require the following contexts :
Internal Interrupt :
Source of interrupt is a memory resident process or an
event within a processor (due to divide by zero or attempt
to execute an illegal instruction).
Some times malfunctions caused by events
like divide by zero are called traps.
Timer interrupts may also occur as in RTOSs.
Interrupt Types -1
P.C.P Bhatt OS/M5/V1/2004 18
¾ External Interrupts :
Source of interrupt is not internal i.e. other than a process
or processor related event.
Can be caused by a device seeking attention of a processor.
IO device interrupting a program that had sought IO
(mentioned earlier) is an external interrupt.
Interrupt Types -2
P.C.P Bhatt OS/M5/V1/2004 19
¾ Software Interrupt :
Most OSs offer two modes of operation – user mode and
system mode.
A system call made by a user program will require a
transition from user mode to system mode – this
generates a software interrupt.
Interrupt Types -3
P.C.P Bhatt OS/M5/V1/2004 20
Interrupt Line
IRQ
Recognized
End of
Instruction
Interrupt Recognition
Hardware Support to Recognize Interrupt
P.C.P Bhatt OS/M5/V1/2004 21
Let us see how an interrupt is serviced :
Suppose program P is executing an instruction i when
an interrupt is raised.
Assume also an interrupt service routine ISR to be
initiated to service the interrupt.
Interrupt Servicing -1
P.C.P Bhatt OS/M5/V1/2004 22
The following steps describe how the interrupt service
may happen :
1. Suspend the current program P after executing
instruction i.
2. Store address of instruction i+1 in P as return address
for P – PADDRi+1 which is the incremented program
counter value.
This may be stored (RESTORE) in some specific
location or a systems’ data structure or in the code
area of ISR itself.
Interrupt Servicing -2
P.C.P Bhatt OS/M5/V1/2004 23
3. A branch unconditionally to interrupt service
instructions in ISR happens.
4. Typically, the last instruction in the service routine ISR
executes a branch indirect from RESTORE. This
restores the program counter a branch indirect
instruction from PADDRi+1
Thus the suspended program P obtains control of the
processor again.
Interrupt Servicing -3
P.C.P Bhatt OS/M5/V1/2004 24
We will see how source of interrupt may be identified in
the context of different I/O mechanisms like:
Polling :
It interrogates all the devices in sequence
It is slow if there are many devices.
Identification of Source of Interrupts -1
P.C.P Bhatt OS/M5/V1/2004 25
Interrupt Line
CPU
INT Address
----------
--------
Daisy Chain
Identification of Source of Interrupts -2
P.C.P Bhatt OS/M5/V1/2004 26
Pointer to
Service Routine
Vectored Interrupt
Identification of Source of Interrupts -3
P.C.P Bhatt OS/M5/V1/2004 27
HW/SW Interface
P.C.P Bhatt OS/M5/V1/2004 28
9 Usually, an OS kernel resolves IO commands.
9 Following an issuance of an IO command, the kernel
communicates with individual device drivers; which in
turn communicate with IO devices.
9 The application at the top level communicates only
with the kernel.
I/O and the Kernel -1
P.C.P Bhatt OS/M5/V1/2004 29
9 Each IO request from an application generates the
following:
¾ Naming or identification of the device to
communicate.
¾ Providing device independent data to
communicate.
I/O and the Kernel -2
P.C.P Bhatt OS/M5/V1/2004 30
I/O and the Kernel -3
IIO channel: is a small computer to handle IO from multiple sources
-smoothes out IO traffic.
Applications Devices
P.C.P Bhatt OS/M5/V1/2004 31
9 Kernel IO subsystem arranges for the following:
¾ Identification of the device driver.
¾ Allocation of buffers.
¾ Reporting of errors.
¾ Tracking the device usage.
I/O and the Kernel -4
P.C.P Bhatt OS/M5/V1/2004 32
9 The device driver transfers the kernel IO request to
set device controller with the following information :
• Identify read/write request.
• Set controller registers for data transfer (Data
count = 0; where to locate data)
• Keep track when the data has been transferred
(when fresh data is to be brought in).
I/O and the Kernel -5
P.C.P Bhatt OS/M5/V1/2004 33
Device Driver Operation
The figure below shows the sequence which device drivers
follow to handle interrupts:
P.C.P Bhatt OS/M5/V1/2004 34
Management Buffer -1
Example in the figure shows how at different stages the buffer
sizes may differ.
P.C.P Bhatt OS/M5/V1/2004 35
Buffers are usually set up in the main memory or in caches.
Caches are used to obtain enhanced performance.
Buffers absorb mismatch in the data transfer rates of the
processor or memory on one side and the device on the
other.
Management of Buffers - 2
P.C.P Bhatt OS/M5/V1/2004 36
Assume we are seeking input of data from a device. The
various buffering strategies are as follows:
Single buffer : The device first fills a buffer.
Next the device driver hands in its control to the kernel
to input the data in the buffer.
Once the buffer has been used up, the device fills it up
again for input.
Management of Buffers - 3
P.C.P Bhatt OS/M5/V1/2004 37
Double buffer : Here there are 2 buffers.
Device driver starts by filling buffer-0 and then hands it
to the kernel to be emptied.
In the meanwhile it starts to fill buffer-1.
The roles are switched when buffer-1 is filled out.
Management of Buffers - 4
P.C.P Bhatt OS/M5/V1/2004 38
Circular buffer : One can say that double buffer is a circular
queue of size 2.
We can have many buffers in a circular queue.
Kernel accesses filled out buffers in the same order that these are
filled out.
Note that buffer management requires management of a queue
data structure.
One must have pointers to the head and tail of this queue to
determine if it is full or empty.
Management of Buffers - 5
P.C.P Bhatt OS/M5/V1/2004 39
Buffering Schemes
P.C.P Bhatt OS/M5/V1/2004 40
Spooling in Printers
Consider a printer connected to a machine and several
users wanting to use it.
To avoid print clashes, all the print requests are
SPOOLED and thus the requests are queued.
OS maintains and schedules all print requests.
We can examine print queue status with lpq and lpstat
commands in Unix.
Additional Considerations
P.C.P Bhatt OS/M5/V1/2004 41
Clocks and Management of Time -1
Clocks : CPU has a system clock. OS uses this clock to
provide a variety of system and application based services
such as :
• Maintaining time of day (date command in Unix)
• Scheduling a program run at a specified time during
systems’ operation (cron command)
Additional Considerations
P.C.P Bhatt OS/M5/V1/2004 42
Clocks and Management of Time -2
•Providing over runs by processes in preemptive scheduling
- important for real-time systems.
• Keeping track of resource utilization or reserving
resource use.
• Performance related measurements (like timing IO,
CPU activity).
Additional Considerations
P.C.P Bhatt OS/M5/V1/2004 43
Identifying Devices
Addressing a device :
•Most OSs reserve some address space for use as exclusive
addresses for devices (like DMA controllers, timer, serial
ports).
•Each of them have fixed ranges of addresses so that they
communicate with the right ports of data.
Additional Considerations
P.C.P Bhatt OS/M5/V1/2004 44
Caching -1
•A cache is an intermediate level fast storage.
•Caches are regarded as fast buffers.
•Caching may be between disk and memory or memory and
CPU.
•It helps in overcoming the latency during an instruction
fetch.
•It helps in higher locality of reference when used for data.
Additional Considerations
P.C.P Bhatt OS/M5/V1/2004 45
Caching -1
•As for main memory to disk caches, one use is in disk
rewrites.
•This technique is used almost always to collect all write
requests over a short period of time and subsequently it is
actually written into disc.
•Caching is always done to enhance the performance of
systems.
Additional Considerations
P.C.P Bhatt OS/M5/V1/2004 46
IO channels : an IO channel is primarily a small computer
to basically handle IO from multiple sources - smoothes
out IO traffic.
OS and CDE : OS provides several terminal oriented
facilities for operations in a Common Desktop
Environment.
IO kernel provides all screen management functions
within the frame work of a CDE.
Additional Considerations
P.C.P Bhatt OS/M5/V1/2004 47
Primary memory is volatile and secondary memory is
non-volatile.
Primary memory loses its information when power goes
off; unlike secondary memory.
The most common secondary storage is a disc.
Motivation for Disc Scheduling
P.C.P Bhatt OS/M5/V1/2004 48
Information Storage
Organization on Discs - 1
P.C.P Bhatt OS/M5/V1/2004 49
A disc has several platters each with several rings or tracks.
Rings are divided into sectors where information is actually
stored.
Sequentially related information is organized into cylinders.
Information on different cylinders has to be accessed by
moving the arm – seek latency.
Information Storage
Organization on Discs - 2
P.C.P Bhatt OS/M5/V1/2004 50
Rotational delay is due to the waiting time for a sector in
rotation to come under the read or write head.
The motivation for disc scheduling comes from the need
to keep both the delays to a minimum.
A sector stores a lot of other information in addition to a
block of information
Delays in Information Retrieval -1
P.C.P Bhatt OS/M5/V1/2004 51
Information Storage in Sectors.
Delays in Information Retrieval -1
Note that we require 10% of extra information for a 512 byte
data. Clearly, for larger block sizes this constant over head
becomes less significant. However, larger block sizes would
require larger buffers.
P.C.P Bhatt OS/M5/V1/2004 52
A user communicates with files (program, data, system utilities
etc.) stored on discs. All such communications have the
following components.
¾ The IO is to read from, or write into, a disc.
¾ The starting address for communication in main
¾ memory.
¾The amount of information to be communicated
¾The starting address in disc and current status of the transfer.
Scheduling Disk Operations -1
P.C.P Bhatt OS/M5/V1/2004 53
¾Consider a scenario of one process with one request to access data;
a disc access request leads finally to the cylinder having that data.
¾When multiple requests are pending on a disc, accessing
information in a certain order becomes essential – disc access
scheduling.
For example, if there are 200 tracks on each platter, pending requests
may come in the order – 59, 41, 172, 74, 52, 85, 139, 12, 194 and 87.
A Scenario for Information Retrieval
P.C.P Bhatt OS/M5/V1/2004 54
FCFS Policy : The service is provided strictly in the
sequence in which the requests arrived.
The service would be in the sequence :
59, 41, 172, 74, 52, 85, 139, 12, 194 and 87.
In order to compare the effect of implementing a certain
policy, we analyze the arm movements – captures the
basic disc activity.
Comparison of Policies -1
P.C.P Bhatt OS/M5/V1/2004 55
Disc Scheduling Policies
Assume that the arm is located at cylinder number 100.
Comparison of Policies -2
P.C.P Bhatt OS/M5/V1/2004 56
Shortest Seek First : Disc access is in the order:
87, 85, 74, 59, 52, 41, 12, 139, 172, 194.
Elevator Algorithm : Assume an initial movement is in a
certain direction. Disc access is in the following order :
139, 172, 194, 87, 85, 74, 59, 41, 12.
Comparison of Policies -3
P.C.P Bhatt OS/M5/V1/2004 57
Circular Span : This scan policy is done in one
direction and wraps around. The disc access will be in
the following order:
139, 172, 174, 12, 41, 52, 59, 74, 85, 87.
From these graphs we find that FCFS is not a very good
policy; Shortest Seek First and Elevator algorithm seem
to perform well as these have least arm movements.
Comparison of Policies -4

More Related Content

Similar to Input output concepts in operating systems

Unit2 p1 io organization-97-2003
Unit2 p1 io organization-97-2003Unit2 p1 io organization-97-2003
Unit2 p1 io organization-97-2003Swathi Veeradhi
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organizationchidabdu
 
Computer architecture presentation
Computer architecture presentationComputer architecture presentation
Computer architecture presentationMuhammad Hamza
 
IOhardware_operting_systems_2022_libya.pdf
IOhardware_operting_systems_2022_libya.pdfIOhardware_operting_systems_2022_libya.pdf
IOhardware_operting_systems_2022_libya.pdfaptinstallpython3
 
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxFANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxPannaBushratul
 
Bca examination 2015 csa
Bca examination 2015 csaBca examination 2015 csa
Bca examination 2015 csaAnjaan Gajendra
 
Chapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxChapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxJanethMedina31
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdfAkritiPradhan2
 
Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputPeter Tröger
 
Input Output Operations
Input Output OperationsInput Output Operations
Input Output Operationskdisthere
 
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxUNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxLeahRachael
 

Similar to Input output concepts in operating systems (20)

Ch 01 os8e
Ch 01  os8eCh 01  os8e
Ch 01 os8e
 
Unit 6
Unit 6Unit 6
Unit 6
 
Unit2 p1 io organization-97-2003
Unit2 p1 io organization-97-2003Unit2 p1 io organization-97-2003
Unit2 p1 io organization-97-2003
 
IO hardware
IO hardwareIO hardware
IO hardware
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organization
 
Computer architecture presentation
Computer architecture presentationComputer architecture presentation
Computer architecture presentation
 
IOhardware_operting_systems_2022_libya.pdf
IOhardware_operting_systems_2022_libya.pdfIOhardware_operting_systems_2022_libya.pdf
IOhardware_operting_systems_2022_libya.pdf
 
I/O Organization
I/O OrganizationI/O Organization
I/O Organization
 
IO organization.ppt
IO organization.pptIO organization.ppt
IO organization.ppt
 
Ca 2 note mano
Ca 2 note manoCa 2 note mano
Ca 2 note mano
 
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxFANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
 
Bca examination 2015 csa
Bca examination 2015 csaBca examination 2015 csa
Bca examination 2015 csa
 
Chapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxChapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptx
 
Io pro
Io proIo pro
Io pro
 
Operating System Lecture 2
Operating System Lecture 2Operating System Lecture 2
Operating System Lecture 2
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
 
Io systems final
Io systems finalIo systems final
Io systems final
 
Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / Output
 
Input Output Operations
Input Output OperationsInput Output Operations
Input Output Operations
 
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxUNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
 

Recently uploaded

Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfragupathi90
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New HorizonMorshed Ahmed Rahath
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsVIEW
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUUNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUankushspencer015
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxCHAIRMAN M
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniR. Sosa
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxMANASINANDKISHORDEOR
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxMustafa Ahmed
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligencemahaffeycheryld
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfSkNahidulIslamShrabo
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfJNTUA
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological universityMohd Saifudeen
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxKarpagam Institute of Teechnology
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfssuser5c9d4b1
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..MaherOthman7
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptamrabdallah9
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksIJECEIAES
 

Recently uploaded (20)

Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUUNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptx
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdf
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 

Input output concepts in operating systems

  • 1. P.C.P Bhatt OS/M5/V1/2004 1 Input Output (IO) Management Prof. P.C.P. Bhatt
  • 2. P.C.P Bhatt OS/M5/V1/2004 2 • Humans interact with machines by providing information through IO devices. • Many on-line services are availed through use of specialized devices like printers, keyboards etc. • Management of these devices can affect the throughput of a system. Introduction
  • 3. P.C.P Bhatt OS/M5/V1/2004 3 Communication with an IO device is required at the following levels: ¾ The need for a human to input information and output from a computer. ¾ The need for a device to input information and receive output from a computer. ¾ The need for computers to communicate over networks. Issues in IO Management
  • 4. P.C.P Bhatt OS/M5/V1/2004 4 ¾Character oriented input devices operate with speeds of tens of bytes per second. ¾Block oriented devices are much faster than character oriented devices. Also note that they operate over a much wider range. Devices communicate bit or byte streams with a machine using a data bus and a device controller. Device Speeds
  • 5. P.C.P Bhatt OS/M5/V1/2004 5 • A computer system may have to synchronize with some other process to communicate. • So, one process may actually wait at the point of rendezvous for the other process to arrive. • The process advances further following the synchronizing event. Event Based I/O -1
  • 6. P.C.P Bhatt OS/M5/V1/2004 6 • Processes may use signals to communicate events. • Processes may wait for asynchronous events to occur. • Every OS provides a set of mechanisms which may be like polling, or a programmed data transfer, or an interrupt mechanism, or even use DMA with cycle stealing. Event Based I/O -2
  • 7. P.C.P Bhatt OS/M5/V1/2004 7 IO Organization -1 Computers employ the four basic modes of IO operation: These are: 1. Polling 2. Programmed mode 3. Interrupt mode 4. DMA mode
  • 8. P.C.P Bhatt OS/M5/V1/2004 8 Polling • Polling: Computer interrogates each device in turn to determine if it is ready to communicate. • Polling as a strategy is also used by systems to interrogate ports on a computer communication network.
  • 9. P.C.P Bhatt OS/M5/V1/2004 9 9 Programmed mode : An IO instruction is issued to a device. Now the program busy-waits (idles) till the device IO is completed. In other words execution of I/O instruction is in sequence with other program instructions. Programmed mode
  • 10. P.C.P Bhatt OS/M5/V1/2004 10 9 Interrupt mode : An IO instruction is issued. The program advances without suspension till the device is actually ready to establish an IO, when the process is suspended. Interrupt mode
  • 11. P.C.P Bhatt OS/M5/V1/2004 11 9 DMA mode : The device requests for an IO for a block data transfer. The execution is briefly suspended and the starting address and size of data block are stored in a DMA controller. DMA mode
  • 12. P.C.P Bhatt OS/M5/V1/2004 12 9 Programmed IO is used for synchronizing information or when speed is not critical, e.g. – in the i386 CPU based PC architecture, there is a notion of listening to an IO port. 9 Interrupt transfer is suited for a small amount of critical information – no more than tens of bytes. 9 DMA is used mostly for block devices. IO Modes: some observations
  • 13. P.C.P Bhatt OS/M5/V1/2004 13 Direct Memory Access Mode of Data Transfer
  • 14. P.C.P Bhatt OS/M5/V1/2004 14 Network oriented traffic can be handled in DMA mode. Network traffic usually corresponds to getting information from a disc file at both ends and network traffic is bursty. In all the above modes, OS makes it look as if we are doing a read or a write operation on a file. Network oriented traffic
  • 15. P.C.P Bhatt OS/M5/V1/2004 15 In this mode, an IO instruction is issued and the program advances without suspension. Program suspension happens when the device is actually ready to establish an IO. An Interrupt Service Routine is executed to achieve device IO. Interrupt Mode - 1
  • 16. P.C.P Bhatt OS/M5/V1/2004 16 Process context is stored to help resume computation later (from the point of suspension.) Program resumes execution from where it was suspended. Interrupt Mode - 2
  • 17. P.C.P Bhatt OS/M5/V1/2004 17 Interrupt processing may require the following contexts : Internal Interrupt : Source of interrupt is a memory resident process or an event within a processor (due to divide by zero or attempt to execute an illegal instruction). Some times malfunctions caused by events like divide by zero are called traps. Timer interrupts may also occur as in RTOSs. Interrupt Types -1
  • 18. P.C.P Bhatt OS/M5/V1/2004 18 ¾ External Interrupts : Source of interrupt is not internal i.e. other than a process or processor related event. Can be caused by a device seeking attention of a processor. IO device interrupting a program that had sought IO (mentioned earlier) is an external interrupt. Interrupt Types -2
  • 19. P.C.P Bhatt OS/M5/V1/2004 19 ¾ Software Interrupt : Most OSs offer two modes of operation – user mode and system mode. A system call made by a user program will require a transition from user mode to system mode – this generates a software interrupt. Interrupt Types -3
  • 20. P.C.P Bhatt OS/M5/V1/2004 20 Interrupt Line IRQ Recognized End of Instruction Interrupt Recognition Hardware Support to Recognize Interrupt
  • 21. P.C.P Bhatt OS/M5/V1/2004 21 Let us see how an interrupt is serviced : Suppose program P is executing an instruction i when an interrupt is raised. Assume also an interrupt service routine ISR to be initiated to service the interrupt. Interrupt Servicing -1
  • 22. P.C.P Bhatt OS/M5/V1/2004 22 The following steps describe how the interrupt service may happen : 1. Suspend the current program P after executing instruction i. 2. Store address of instruction i+1 in P as return address for P – PADDRi+1 which is the incremented program counter value. This may be stored (RESTORE) in some specific location or a systems’ data structure or in the code area of ISR itself. Interrupt Servicing -2
  • 23. P.C.P Bhatt OS/M5/V1/2004 23 3. A branch unconditionally to interrupt service instructions in ISR happens. 4. Typically, the last instruction in the service routine ISR executes a branch indirect from RESTORE. This restores the program counter a branch indirect instruction from PADDRi+1 Thus the suspended program P obtains control of the processor again. Interrupt Servicing -3
  • 24. P.C.P Bhatt OS/M5/V1/2004 24 We will see how source of interrupt may be identified in the context of different I/O mechanisms like: Polling : It interrogates all the devices in sequence It is slow if there are many devices. Identification of Source of Interrupts -1
  • 25. P.C.P Bhatt OS/M5/V1/2004 25 Interrupt Line CPU INT Address ---------- -------- Daisy Chain Identification of Source of Interrupts -2
  • 26. P.C.P Bhatt OS/M5/V1/2004 26 Pointer to Service Routine Vectored Interrupt Identification of Source of Interrupts -3
  • 27. P.C.P Bhatt OS/M5/V1/2004 27 HW/SW Interface
  • 28. P.C.P Bhatt OS/M5/V1/2004 28 9 Usually, an OS kernel resolves IO commands. 9 Following an issuance of an IO command, the kernel communicates with individual device drivers; which in turn communicate with IO devices. 9 The application at the top level communicates only with the kernel. I/O and the Kernel -1
  • 29. P.C.P Bhatt OS/M5/V1/2004 29 9 Each IO request from an application generates the following: ¾ Naming or identification of the device to communicate. ¾ Providing device independent data to communicate. I/O and the Kernel -2
  • 30. P.C.P Bhatt OS/M5/V1/2004 30 I/O and the Kernel -3 IIO channel: is a small computer to handle IO from multiple sources -smoothes out IO traffic. Applications Devices
  • 31. P.C.P Bhatt OS/M5/V1/2004 31 9 Kernel IO subsystem arranges for the following: ¾ Identification of the device driver. ¾ Allocation of buffers. ¾ Reporting of errors. ¾ Tracking the device usage. I/O and the Kernel -4
  • 32. P.C.P Bhatt OS/M5/V1/2004 32 9 The device driver transfers the kernel IO request to set device controller with the following information : • Identify read/write request. • Set controller registers for data transfer (Data count = 0; where to locate data) • Keep track when the data has been transferred (when fresh data is to be brought in). I/O and the Kernel -5
  • 33. P.C.P Bhatt OS/M5/V1/2004 33 Device Driver Operation The figure below shows the sequence which device drivers follow to handle interrupts:
  • 34. P.C.P Bhatt OS/M5/V1/2004 34 Management Buffer -1 Example in the figure shows how at different stages the buffer sizes may differ.
  • 35. P.C.P Bhatt OS/M5/V1/2004 35 Buffers are usually set up in the main memory or in caches. Caches are used to obtain enhanced performance. Buffers absorb mismatch in the data transfer rates of the processor or memory on one side and the device on the other. Management of Buffers - 2
  • 36. P.C.P Bhatt OS/M5/V1/2004 36 Assume we are seeking input of data from a device. The various buffering strategies are as follows: Single buffer : The device first fills a buffer. Next the device driver hands in its control to the kernel to input the data in the buffer. Once the buffer has been used up, the device fills it up again for input. Management of Buffers - 3
  • 37. P.C.P Bhatt OS/M5/V1/2004 37 Double buffer : Here there are 2 buffers. Device driver starts by filling buffer-0 and then hands it to the kernel to be emptied. In the meanwhile it starts to fill buffer-1. The roles are switched when buffer-1 is filled out. Management of Buffers - 4
  • 38. P.C.P Bhatt OS/M5/V1/2004 38 Circular buffer : One can say that double buffer is a circular queue of size 2. We can have many buffers in a circular queue. Kernel accesses filled out buffers in the same order that these are filled out. Note that buffer management requires management of a queue data structure. One must have pointers to the head and tail of this queue to determine if it is full or empty. Management of Buffers - 5
  • 39. P.C.P Bhatt OS/M5/V1/2004 39 Buffering Schemes
  • 40. P.C.P Bhatt OS/M5/V1/2004 40 Spooling in Printers Consider a printer connected to a machine and several users wanting to use it. To avoid print clashes, all the print requests are SPOOLED and thus the requests are queued. OS maintains and schedules all print requests. We can examine print queue status with lpq and lpstat commands in Unix. Additional Considerations
  • 41. P.C.P Bhatt OS/M5/V1/2004 41 Clocks and Management of Time -1 Clocks : CPU has a system clock. OS uses this clock to provide a variety of system and application based services such as : • Maintaining time of day (date command in Unix) • Scheduling a program run at a specified time during systems’ operation (cron command) Additional Considerations
  • 42. P.C.P Bhatt OS/M5/V1/2004 42 Clocks and Management of Time -2 •Providing over runs by processes in preemptive scheduling - important for real-time systems. • Keeping track of resource utilization or reserving resource use. • Performance related measurements (like timing IO, CPU activity). Additional Considerations
  • 43. P.C.P Bhatt OS/M5/V1/2004 43 Identifying Devices Addressing a device : •Most OSs reserve some address space for use as exclusive addresses for devices (like DMA controllers, timer, serial ports). •Each of them have fixed ranges of addresses so that they communicate with the right ports of data. Additional Considerations
  • 44. P.C.P Bhatt OS/M5/V1/2004 44 Caching -1 •A cache is an intermediate level fast storage. •Caches are regarded as fast buffers. •Caching may be between disk and memory or memory and CPU. •It helps in overcoming the latency during an instruction fetch. •It helps in higher locality of reference when used for data. Additional Considerations
  • 45. P.C.P Bhatt OS/M5/V1/2004 45 Caching -1 •As for main memory to disk caches, one use is in disk rewrites. •This technique is used almost always to collect all write requests over a short period of time and subsequently it is actually written into disc. •Caching is always done to enhance the performance of systems. Additional Considerations
  • 46. P.C.P Bhatt OS/M5/V1/2004 46 IO channels : an IO channel is primarily a small computer to basically handle IO from multiple sources - smoothes out IO traffic. OS and CDE : OS provides several terminal oriented facilities for operations in a Common Desktop Environment. IO kernel provides all screen management functions within the frame work of a CDE. Additional Considerations
  • 47. P.C.P Bhatt OS/M5/V1/2004 47 Primary memory is volatile and secondary memory is non-volatile. Primary memory loses its information when power goes off; unlike secondary memory. The most common secondary storage is a disc. Motivation for Disc Scheduling
  • 48. P.C.P Bhatt OS/M5/V1/2004 48 Information Storage Organization on Discs - 1
  • 49. P.C.P Bhatt OS/M5/V1/2004 49 A disc has several platters each with several rings or tracks. Rings are divided into sectors where information is actually stored. Sequentially related information is organized into cylinders. Information on different cylinders has to be accessed by moving the arm – seek latency. Information Storage Organization on Discs - 2
  • 50. P.C.P Bhatt OS/M5/V1/2004 50 Rotational delay is due to the waiting time for a sector in rotation to come under the read or write head. The motivation for disc scheduling comes from the need to keep both the delays to a minimum. A sector stores a lot of other information in addition to a block of information Delays in Information Retrieval -1
  • 51. P.C.P Bhatt OS/M5/V1/2004 51 Information Storage in Sectors. Delays in Information Retrieval -1 Note that we require 10% of extra information for a 512 byte data. Clearly, for larger block sizes this constant over head becomes less significant. However, larger block sizes would require larger buffers.
  • 52. P.C.P Bhatt OS/M5/V1/2004 52 A user communicates with files (program, data, system utilities etc.) stored on discs. All such communications have the following components. ¾ The IO is to read from, or write into, a disc. ¾ The starting address for communication in main ¾ memory. ¾The amount of information to be communicated ¾The starting address in disc and current status of the transfer. Scheduling Disk Operations -1
  • 53. P.C.P Bhatt OS/M5/V1/2004 53 ¾Consider a scenario of one process with one request to access data; a disc access request leads finally to the cylinder having that data. ¾When multiple requests are pending on a disc, accessing information in a certain order becomes essential – disc access scheduling. For example, if there are 200 tracks on each platter, pending requests may come in the order – 59, 41, 172, 74, 52, 85, 139, 12, 194 and 87. A Scenario for Information Retrieval
  • 54. P.C.P Bhatt OS/M5/V1/2004 54 FCFS Policy : The service is provided strictly in the sequence in which the requests arrived. The service would be in the sequence : 59, 41, 172, 74, 52, 85, 139, 12, 194 and 87. In order to compare the effect of implementing a certain policy, we analyze the arm movements – captures the basic disc activity. Comparison of Policies -1
  • 55. P.C.P Bhatt OS/M5/V1/2004 55 Disc Scheduling Policies Assume that the arm is located at cylinder number 100. Comparison of Policies -2
  • 56. P.C.P Bhatt OS/M5/V1/2004 56 Shortest Seek First : Disc access is in the order: 87, 85, 74, 59, 52, 41, 12, 139, 172, 194. Elevator Algorithm : Assume an initial movement is in a certain direction. Disc access is in the following order : 139, 172, 194, 87, 85, 74, 59, 41, 12. Comparison of Policies -3
  • 57. P.C.P Bhatt OS/M5/V1/2004 57 Circular Span : This scan policy is done in one direction and wraps around. The disc access will be in the following order: 139, 172, 174, 12, 41, 52, 59, 74, 85, 87. From these graphs we find that FCFS is not a very good policy; Shortest Seek First and Elevator algorithm seem to perform well as these have least arm movements. Comparison of Policies -4