0% found this document useful (0 votes)
36 views16 pages

Unit 5 Os Notes

The document discusses input/output (I/O) management in operating systems. It describes different types of I/O devices, device drivers, methods of communication with devices like memory mapping and direct memory access (DMA). It also covers I/O buffering techniques like single, double and circular buffers and file systems including file allocation methods like contiguous and linked allocation.

Uploaded by

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

Unit 5 Os Notes

The document discusses input/output (I/O) management in operating systems. It describes different types of I/O devices, device drivers, methods of communication with devices like memory mapping and direct memory access (DMA). It also covers I/O buffering techniques like single, double and circular buffers and file systems including file allocation methods like contiguous and linked allocation.

Uploaded by

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

Unit -5

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 8−
• 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 drivers/Controller:
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. The device driver has
following characteristics: -

• per each device type


• responsible for device access management and control
• provided by device manufacturers per OS /version
• each OS standardizes interfaces
• device independence
• device diversity

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)
1. Special Instruction I/O
This uses CPU instructions that are speci7-\9
fically 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.
2. 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.

3. 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.
I/O buffering:
A buffer is a memory area that stores data being transferred between two devices or
between a device and an application.
Uses of I/O Buffering:
• Buffering is done to deal effectively with a speed mismatch between the
producer and consumer of the data stream.
• A buffer is produced in main memory to heap up the bytes received from
modem.
• After receiving the data in the buffer, the data get transferred to disk from buffer
in a single operation.
• This process of data transfer is not instantaneous; therefore, the modem needs
another buffer in order to store additional incoming data.
• Buffering also provides variations for devices that have different data transfer
sizes.

Types of various I/O buffering techniques:


1.Single buffer:
A buffer is provided by the operating system to the system portion of the main memory.
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 work
simultaneously, when one block 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.

2. Double buffer:
• There are two buffers in the system.
• One buffer is used by the driver or controller to store data while waiting for it to
be taken by higher level of the hierarchy.
• Other buffer is used to store data from the lower level module.
• Double buffering is also known as buffer swapping.
• A major disadvantage of double buffering is that the complexity of the process
get increased.
• If the process performs rapid bursts of I/O, then using double buffering may be
deficient.

3.Circular buffer:

• When more than two buffers are used, the collection of buffers is itself referred
to as a circular buffer.
• In this, the data do not directly passed from the producer to the consumer
because the data would change due to overwriting of buffers before they had
been consumed.
• The producer can only fill up to buffer i-1 while data in buffer i is waiting to be
consumed.

File Systems in Operating System


A file is a collection of related information that is recorded on secondary storage. Or file is
a collection of logically related entities. From user’s perspective a file is the smallest
allotment of logical secondary storage.
The name of the file is divided into two parts as shown below:
• name
• extension, separated by a period.
FILE DIRECTORIES:
Collection of files is a file directory. The directory contains information about the files,
including attributes, location and ownership. Much of this information, especially that is
concerned with storage, is managed by the operating system. The directory is itself a file,
accessible by various file management routines.

Information contained in a device directory are:


• Name
• Type
• Address
• Current length
• Maximum length
• Date last accessed
• Date last updated
• Owner id
• Protection information

Operation performed on directory are:


• Search for a file
• Create a file
• Delete a file
• List a directory
• Rename a file
• Traverse the file system

Advantages of maintaining directories are:


• Efficiency: A file can be located more quickly.
• Naming: It becomes convenient for users as two users can have same name for
different files or may have different name for same file.
• Grouping: Logical grouping of files can be done by properties e.g. all java
programs, all games etc.

Types of file Directory:


i. SINGLE-LEVEL DIRECTORY:
In this a single directory is maintained for all the users.
• Naming problem: Users cannot have same name for two files.
• Grouping problem: Users cannot group files according to their need.
ii. TWO-LEVEL DIRECTORY:
In this separate directories for each user is maintained.

• Path name:Due to two levels there is a path name for every file to locate that
file.
• Now,we can have same file name for different user.
• Searching is efficient in this method.

iii. TREE-STRUCTURED DIRECTORY :


Directory is maintained in the form of a tree. Searching is efficient and also there is
grouping capability. We have absolute or relative path name for a file.

FILE ALLOCATION METHODS :

1. Contiguous Allocation–

A single continuous set of blocks is allocated to a file at the time of file creation. Thus, this
is a pre-allocation strategy, using variable size portions. The file allocation table needs just a
single entry for each file, showing the starting block and the length of the file. If the blocks
are allocated to the file in such a way that all the logical blocks of the file get the contiguous
physical block in the hard disk then such allocation scheme is known as contiguous allocation.

In the image shown below, there are three files in the directory. The starting block and the
length of each file are mentioned in the table. We can check in the table that the contiguous
blocks are assigned to each file as per its need.

Disadvantage –
• External fragmentation will occur, making it difficult to find contiguous blocks
of space of sufficient length. Compaction algorithm will be necessary to free up
additional space on disk.
• Also, with pre-allocation, it is necessary to declare the size of the file at the time
of creation.

2. Linked Allocation(Non-contiguous allocation) –

Allocation is on an individual block basis. Each block contains a pointer to the next block in
the chain. Again the file table needs just a single entry for each file, showing the starting
block and the length of the file. Although pre-allocation is possible, it is more common
simply to allocate blocks as needed. Any free block can be added to the chain. The blocks
need not be continuous. Increase in file size is always possible if free disk block is available.
There is no external fragmentation because only one block at a time is needed but there can
be internal fragmentation but it exists only in the last disk block of file.
Disadvantage –
• Internal fragmentation exists in last disk block of file.
• There is an overhead of maintaining the pointer in every disk block.
• If the pointer of any disk block is lost, the file will be truncated.
• It supports only the sequential access of files.

3. Indexed Allocation –
It addresses many of the problems of contiguous and chained allocation. In this case, the
file allocation table contains a separate one-level index for each file: The index has one
entry for each block allocated to the file. Allocation may be on the basis of fixed-size
blocks or variable-sized blocks. Allocation by blocks eliminates external fragmentation,
whereas allocation by variable-size blocks improves locality. This allocation technique
supports both sequential and direct access to the file and thus is the most popular form of
file allocation.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy