Chapter 4 Os
Chapter 4 Os
Device management
Contents
What is device management
Characteristics of parallel and serial devices
Buffering strategies
Direct memory access
Recovery from failure
What is device management
• Device Management is another important function of the
operating system.
• Device management is responsible for managing all the
hardware devices of the computer system.
• It may also include the management of the storage device as
well as the management of all the input and output devices of the
computer system.
• Device management is the management of I/O devices such as a
keyboard, magnetic tape, disk, printer, microphone, USB ports,
scanner, and other supporting units such as control channels in
an operating system.
In the operating system, there is a device management technique.
• Through its individual drivers, an operating system, or OS,
oversees communication with the devices.
Cont..
• The operating system component creates a standardized interface
for accessing devices with various physical characteristics.
• In order to control devices in the operating system
Keep tracks of all devices and the program which is
responsible to perform this is called I/O controller.
Monitoring the status of each device such as storage drivers,
printers and other peripheral devices.
Enforcing preset policies and taking a decision which
process gets the device when and for how long.
Allocates and De-allocates the device in an efficient way.
De-allocating them at two levels: at the process level when
I/O command has been executed and the device is
temporarily released, and at the job level, when the job is
finished and the device is permanently released.
Optimizes the performance of individual devices.
Characteristics of parallel and serial devices
• A port is basically a physical docking point which is
basically used to connect the external devices to the
computer, or we can say that A port act as an interface
between the computer and the external devices, e.g., we can
connect hard drives, printers to the computer with the help
of ports.
Features of Computer ports:
• We can connect external devices to the computer with the
help of ports and cables.
• These are basically slots on motherboard where we connect
external devices, or we can plug in external devices through
cables.
• Mouse, keyboards, printers, speakers are some examples of
external devices that connected to the computer through
ports.
Cont..
Types of ports:
1. Serial ports
A serial port is basically a serial communication interface
through which information transforms one bit at a time. It is
one of the oldest type of interfaces.
2. Parallel ports
A parallel port is basically a parallel communication interface
through which information transforms multiple bits at a time.
3. PS/2 ports
These are basically 6 pin mini Din connector used to connect
keyboard, mice to a PC compatible computers.
4. Universal serial bus port
It is basically a standard cable connection interface between
computer and external device. USB is an industrial standard
for short-distance digital data communication.
Cont..
5. VGA Ports
VGA connector stands for Video Graphic Array connector, these
are basically 15 pin connector available in many video-cards,
computer, projectors etc.
Modem Port: These are basically used to connect PC’s modem to
telephone networks.
Ethernet Port: These are basically used to connect Ethernet cables
to the computer. In this data may travel with a speed of 10mb/s to
100 mb/s based on the network bandwidth.
Game Port: These ports are available in computer to connect
joysticks which are now replaced by USB. Digital Video Interface
or we can say DVI Port these are basically used to connect flat
panel LCD Monitor to the computer’s high end video graphics.
Sockets: Sockets are basically used to connect microphone or
speakers to the sound card of the computer
OS I/O sub systems
Buffering strategies
• A buffer is a memory area that stores data being
transferred between two devices or between a device
and an application.
• Buffering is done for three reasons.
• One reason is to cope with a speed mismatch between
the producer and consumer of a data stream.
• A second use of buffering is to provide adaptations for
devices that have different data-transfer sizes.
• Such disparities are especially common in computer
networking, where buffers are used widely for
fragmentation and reassembly of messages.
Cont..
• At the sending side, a large message is fragmented
into small network packets. The packets are sent
over the network, and the receiving side places them
in a reassembly buffer to form an image of the
source data
• A third use of buffering is to support copy
semantics for application I/0.
Cache
• A cache is a region of fast memory that holds copies
of data. Access to the cached copy is more efficient
than access to the original.
• For instance, the instructions of the currently
running process are stored on disk, cached in
physical memory, and copied again in the CPU's
secondary and primary caches.
• The difference between a buffer and a cache is that a
buffer may hold the only existing copy of a data
item, whereas a cache, by definition, holds a copy
on faster storage of an item that resides elsewhere.
Cont..
• Caching and buffering are distinct functions, but
sometimes a region of memory can be used for both
purposes.
• For instance, to preserve copy semantics and to enable
efficient scheduling of disk I/0, the operating system
uses buffers in main memory to hold disk data.
• These buffers are also used as a cache, to improve the
I/O efficiency for files that are shared by applications or
that are being written and reread rapidly.
• When the kernel receives a file I/0 request, the kernel
first accesses the buffer cache to see whether that region
of the file is already available in main memory
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.
• Although a printer can serve only one job at a time, several
applications may wish to print their output concurrently,
without having their output mixed together.
• The operating system solves this problem by intercepting all
output to the printer.
• Each application's output is spooled to a separate disk file.
When an application finishes printing, the spooling system
queues the corresponding spool file for output to the printer.
• The spooling system copies the queued spool files to the
printer one at a time.
Cont..
• In some operating systems, spooling is managed by
a system daemon process. In others, it is handled by
an in-kernel thread.
• In either case, the operating system provides a
control interface that enables users and system
administrators to display the queue, remove
unwanted jobs before those jobs print, suspend
printing while the printer is serviced, and so on.
Error Handling
• An operating system that uses protected memory can guard
against many kinds of hardware and application errors, so
that a complete system failure is not the usual result of each
minor mechanical glitch.
• Devices and I/0 transfers can fail in many ways, either for
transient reasons, as when a network becomes overloaded,
or for "permanent" reasons, as when a disk controller
becomes defective.
• Operating systems can often compensate effectively for
transient failures.
Device drivers
• In computing, a device driver or software driver is a computer
program allowing higher-level computer programs to interact
with a hardware device.
• A driver typically communicates with the device through the
computer bus or communications subsystem to which the
hardware connects.
• When a calling program invokes a routine in the driver, the
driver issues commands to the device.
• Once the device sends data back to the driver, the driver may
invoke routines/procudures in the original calling program.
• Drivers are hardware-dependent and operating-system-specific.
• They usually provide the interrupt handling required for any
necessary asynchronous time-dependent hardware interface.
I/O Scheduling
• To schedule a set of I/O requests means to determine a
good order in which to execute them.
• The order in which applications issue system calls rarely is
the best choice.
• Scheduling can improve overall system performance, can
share device access fairly among processes, and can reduce
the average waiting time for I/0 to complete.
Direct memory access
• For a device that does large transfers, such as a disk drive, it
seems wasteful to use an expensive general-purpose
processor to watch status bits and to feed data into a
controller register one byte at a time-a process termed
programmed I/O(PIO).
• Many computers avoid burdening the main CPU with PIO
by offloading some of this work to a special-purpose
processor called a direct memory access (DMA) controller.
• To initiate a DMA transfer, the host writes a DMA
command block into memory.
• This block contains a pointer to the source of a transfer, a
pointer to the destination of the transfer, and a count of the
number of bytes to be transferred.
Cont..
• The CPU writes the address of this command block to the DMA
controller, then goes on with other work.
• The DMA controller proceeds to operate the memory bus directly,
placing addresses on the bus to perform transfers without the help of
the main CPU.
Recovery from failure
• Backup and recovery describes the process of creating and
storing copies of data that can be used to protect organizations
against data loss.
• This is sometimes referred to as operational recovery. Recovery
from a backup typically involves restoring the data to the
original location, or to an alternate location where it can be used
in place of the lost or damaged data.
• The purpose of the backup is to create a copy of data that can be
recovered in the event of a primary data failure.
• OS failure causes various problems, including loss of temporary
data on the main memory.
• As a result, files are broken or the data of applications are lost.
The general method for restoring an OS facing failure is
rebooting the computer.
• However, the computer is not available for users for tens of
seconds during the rebooting process.
Cont..
• Magnetic disks sometimes fail, and care must be taken to
ensure that the data lost in such a failure are not lost forever.
• To this end, system programs can be used to backup data
from disk to another storage device, such as a floppy disk,
magnetic tape, optical disk, or other hard disk.
• Recovery from the loss of an individual file, or of an entire
disk, may then be a matter of the data from backup.
• To minimize the copying needed, we can use information
from each file's directory entry.
• For instance, if the backup program knows when the last
backup of a file was done, and the file's last write date in the
directory indicates that the file has not changed since that
date, then the file does not need to be copied again.
Cont..
• A typical backup schedule may then be as follows:
1. Copy to a backup medium all files from the disk. This is
called full backup.
2. Copy to another medium all files changed since day This is
called incremental backup.
3. Copy to another medium all files changed since day 4. Day
N. Copy to another medium all files changed since day N-1.
Then go back to Day
End