0% found this document useful (0 votes)
18 views11 pages

Unit 5 (OS) Notes

Uploaded by

sujaybarai46516
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views11 pages

Unit 5 (OS) Notes

Uploaded by

sujaybarai46516
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Unit 5

Operating System - I/O Management


One of the important jobs of an Operating System is to manage
various I/O devices including mouse, keyboards, touch pad, disk drives,
display adapters, USB devices, Bit-mapped screen, LED, Analog-to-
digital converter, On/off switch, network connections, audio I/O, printers
etc.
An I/O system is required to take an application I/O request and send it
to the physical device, then take whatever response comes back from
the device and send it to the application. I/O devices can be divided into
two categories −
 Block devices − A block device is one with which the driver
communicates by sending entire blocks of data. For example, Hard
disks, USB cameras, Disk-On-Key etc.
 Character devices − A character device is one with which the driver
communicates by sending and receiving single characters (bytes,
octets). For example, serial ports, parallel ports, sounds cards etc
Device Controllers
Device drivers are software modules that can be plugged into an OS to
handle a particular device. Operating System takes help from device
drivers to handle all I/O devices.
The Device Controller works like an interface between a device and a
device driver. I/O units (Keyboard, mouse, printer, etc.) typically consist
of a mechanical component and an electronic component where
electronic component is called the device controller.
There is always a device controller and a device driver for each device to
communicate with the Operating Systems. A device controller may be
able to handle multiple devices. As an interface its main task is to
convert serial bit stream to block of bytes, perform error correction as
necessary.
Any device connected to the computer is connected by a plug and
socket, and the socket is connected to a device controller. Following is a
model for connecting the CPU, memory, controllers, and I/O devices
where CPU and device controllers all use a common bus for
communication.
Synchronous vs asynchronous I/O
 Synchronous I/O − In this scheme CPU execution waits while I/O
proceeds
 Asynchronous I/O − I/O proceeds concurrently with CPU execution
Communication to I/O Devices
The CPU must have a way to pass information to and from an I/O
device. There are three approaches available to communicate with the
CPU and Device.
 Special Instruction I/O
 Memory-mapped I/O
 Direct memory access (DMA)

Special Instruction I/O


This uses CPU instructions that are specifically made for controlling I/O
devices. These instructions typically allow data to be sent to an I/O
device or read from an I/O device.
Memory-mapped I/O
When using memory-mapped I/O, the same address space is shared by
memory and I/O devices. The device is connected directly to certain
main memory locations so that I/O device can transfer block of data
to/from memory without going through CPU.
While using memory mapped IO, OS allocates buffer in memory and
informs I/O device to use that buffer to send data to the CPU. I/O device
operates asynchronously with CPU, interrupts CPU when finished.
The advantage to this method is that every instruction which can access
memory can be used to manipulate an I/O device. Memory mapped IO is
used for most high-speed I/O devices like disks, communication
interfaces.
Direct Memory Access (DMA)
Slow devices like keyboards will generate an interrupt to the main CPU
after each byte is transferred. If a fast device such as a disk generated
an interrupt for each byte, the operating system would spend most of its
time handling these interrupts. So a typical computer uses direct
memory access (DMA) hardware to reduce this overhead.
Direct Memory Access (DMA) means CPU grants I/O module authority to
read from or write to memory without involvement. DMA module itself
controls exchange of data between main memory and the I/O device.
CPU is only involved at the beginning and end of the transfer and
interrupted only after entire block has been transferred.
Direct Memory Access needs a special hardware called DMA controller
(DMAC) that manages the data transfers and arbitrates access to the
system bus. The controllers are programmed with source and
destination pointers (where to read/write the data), counters to track
the number of transferred bytes, and settings, which includes I/O and
memory types, interrupts and states for the CPU cycles.
The operating system uses the DMA hardware as follows −
Step Description

1 Device driver is instructed to transfer disk data to a buffer address X.

2 Device driver then instruct disk controller to transfer data to buffer.

3 Disk controller starts DMA transfer.

4 Disk controller sends each byte to DMA controller.

DMA controller transfers bytes to buffer, increases the memory address,


5
decreases the counter C until C becomes zero.

6 When C becomes zero, DMA interrupts CPU to signal transfer completion.

Polling vs Interrupts 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. Both of these techniques allow the processor to
deal with events that can happen at any time and that are not related to
the process it is currently running.
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. The I/O
device simply puts the information in a Status register, and the
processor must come and get the information.
Most of the time, devices will not require attention and when one does it
will have to wait until it is next interrogated by the polling program. This
is an inefficient method and much of the processors time is wasted on
unnecessary polls.
Compare this method to a teacher continually asking every student in a
class, one after another, if they need help. Obviously the more efficient
method would be for a student to inform the teacher whenever they
require assistance.
Interrupts I/O
An alternative scheme for dealing with I/O is the interrupt-driven
method. An interrupt is a signal to the microprocessor from a device
that requires attention.
A device controller puts an interrupt signal on the bus when it needs
CPU’s attention when CPU receives an interrupt, It saves its current
state and invokes the appropriate interrupt handler using the interrupt
vector (addresses of OS routines to handle various events). When the
interrupting device has been dealt with, the CPU continues with its
original task as if it had never been interrupted.
Device Drivers
Device drivers are software modules that can be plugged into an OS to
handle a particular device. Operating System takes help from device
drivers to handle all I/O devices. Device drivers encapsulate device-
dependent code and implement a standard interface in such a way that
code contains device-specific register reads/writes. Device driver, is
generally written by the device's manufacturer and delivered along with
the device on a CD-ROM.
A device driver performs the following jobs −
 To accept request from the device independent software above to
it.
 Interact with the device controller to take and give I/O and perform
required error handling
 Making sure that the request is executed successfully
How a device driver handles a request is as follows: Suppose a request
comes to read a block N. If the driver is idle at the time a request
arrives, it starts carrying out the request immediately. Otherwise, if the
driver is already busy with some other request, it places the new
request in the queue of pending requests.
Interrupt handlers
An interrupt handler, also known as an interrupt service routine or ISR,
is a piece of software or more specifically a callback function in an
operating system or more specifically in a device driver, whose
execution is triggered by the reception of an interrupt.
When the interrupt happens, the interrupt procedure does whatever it
has to in order to handle the interrupt, updates data structures and
wakes up process that was waiting for an interrupt to happen.
The interrupt mechanism accepts an address ─ a number that selects a
specific interrupt handling routine/function from a small set. In most
architectures, this address is an offset stored in a table called the
interrupt vector table. This vector contains the memory addresses of
specialized interrupt handlers.
Device-Independent I/O Software
The basic function of the device-independent software is to perform the
I/O functions that are common to all devices and to provide a uniform
interface to the user-level software. Though it is difficult to write
completely device independent software but we can write some modules
which are common among all the devices. Following is a list of functions
of device-independent I/O Software −
 Uniform interfacing for device drivers
 Device naming - Mnemonic names mapped to Major and Minor
device numbers
 Device protection
 Providing a device-independent block size
 Buffering because data coming off a device cannot be stored in
final destination.
 Storage allocation on block devices
 Allocation and releasing dedicated devices
 Error Reporting

User-Space I/O Software


These are the libraries which provide richer and simplified interface to
access the functionality of the kernel or ultimately interactive with the
device drivers. Most of the user-level I/O software consists of library
procedures with some exception like spooling system which is a way of
dealing with dedicated I/O devices in a multiprogramming system.
I/O Libraries (e.g., stdio) are in user-space to provide an interface to the
OS resident device-independent I/O SW. For example putchar(),
getchar(), printf() and scanf() are example of user level I/O library stdio
available in C programming.
Kernel I/O Subsystem
Kernel I/O Subsystem is responsible to provide many services related to
I/O. Following are some of the services provided.
 Scheduling − Kernel schedules a set of I/O requests to determine a
good order in which to execute them. When an application issues a
blocking I/O system call, the request is placed on the queue for
that device. The Kernel I/O scheduler rearranges the order of the
queue to improve the overall system efficiency and the average
response time experienced by the applications.
 Buffering − Kernel I/O Subsystem maintains a memory area known
as buffer that stores data while they are transferred between two
devices or between a device with an application operation.
Buffering is done to cope with a speed mismatch between the
producer and consumer of a data stream or to adapt between
devices that have different data transfer sizes.
 Caching − Kernel maintains cache memory which is region of fast
memory that holds copies of data. Access to the cached copy is
more efficient than access to the original.
 Spooling and Device Reservation − A spool is a buffer that holds output
for a device, such as a printer, that cannot accept interleaved data
streams. The spooling system copies the queued spool files to the
printer one at a time. In some operating systems, spooling is
managed by a system daemon process. In other operating
systems, it is handled by an in kernel thread.
 Error Handling − An operating system that uses protected memory
can guard against many kinds of hardware and application errors.

Distributed Operating System

These types of operating system is a recent advancement in the world of computer technology
and are being widely accepted all-over the world and, that too, with a great pace. Various
autonomous interconnected computers communicate each other using a shared communication
network.
Independent systems possess their own memory unit and CPU. These are referred as loosely coupled
systems or distributed systems. These system’s processors differ in size and function. The major
benefit of working with these types of operating system is that it is always possible that one user can
access the files or software which are not actually present on his system but on some other system
connected within this network i.e., remote access is enabled within the devices connected in that
network.

Advantages of Distributed Operating System:


 Failure of one will not affect the other network communication, as all systems
are independent from each other
 Electronic mail increases the data exchange speed
 Since resources are being shared, computation is highly fast and durable
 Load on host computer reduces
 These systems are easily scalable as many systems can be easily added to the network
 Delay in data processing reduces
Disadvantages of Distributed Operating System:
 Failure of the main network will stop the entire communication
 To establish distributed systems the language which are used are not well defined yet
 These types of systems are not readily available as they are very expensive. Not only that the
underlying software is highly complex and not understood well yet
Network Operating System
These systems run on a server and provide the capability to manage data, users, groups, security,
applications, and other networking functions. These type of operating systems allow shared access of files,
printers, security, applications, and other networking functions over a small private network. One more
important aspect of Network Operating Systems is that all the users are well aware of the underlying
configuration, of all other users within the network, their individual connections etc. and that’s why these
computers are popularly known as tightly coupled systems.

Advantages of Network Operating System:


 Highly stable centralized servers
 Security concerns are handled through servers
 New technologies and hardware up-gradation are easily integrated to the system
 Server access are possible remotely from different locations and types of systems

Disadvantages of Network Operating System:


 Servers are costly
 User has to depend on central location for most operations
 Maintenance and updates are required regularly

Examples of Network Operating System are: Microsoft Windows Server 2003, Microsoft Windows Server
2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD etc.
Multiprocessor
A Multiprocessor is a computer system with two or more central processing units (CPUs)
share full access to a common RAM. The main objective of using a multiprocessor is to
boost the system’s execution speed, with other objectives being fault tolerance and
application matching.
There are two types of multiprocessors, one is called shared memory multiprocessor and
another is distributed memory multiprocessor. In shared memory multiprocessors, all the
CPUs shares the common memory but in a distributed memory multiprocessor, every CPU
has its own private memory.

Applications of Multiprocessor –
1. As a uniprocessor, such as single instruction, single data stream (SISD).
2. As a multiprocessor, such as single instruction, multiple data stream
(SIMD), which is usually used for vector processing.
3. Multiple series of instructions in a single perspective, such as multiple instruction,
single data stream (MISD), which is used for describing hyper-threading or pipelined
processors.
4. Inside a single system for executing multiple, individual series of instructions
in multiple perspectives, such as multiple instruction, multiple data stream
(MIMD).

Benefits of using a Multiprocessor –


 Enhanced performance.
 Multiple applications.
 Multi-tasking inside an application.
 High throughput and responsiveness.
 Hardware sharing among CPUs.

You might also like