Unit 5 Os Notes
Unit 5 Os Notes
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: -
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.
• 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.
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.
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.