Unit 4 OS 2023
Unit 4 OS 2023
Unit 4 OS 2023
Disk Management:
Operating system is responsible for disk management.
Following are some activities discussed.
Disk Formatting:
1. Low-level formatting, or physical formatting:
Disk must be formatted before storing a disk.
Dividing a disk into sectors that the disk controller can read and write
Low level formatting files the disk with a special data structure for each sector.
Data structures consist of three fields:
Header
Data Area
Trailer
Header and trailer contain information used by the disk controller.
Sector number and Error Correcting Codes (ECC) contained in the Header and Trailer
For writing data to the sector – ECC is updated.
For reading data from the sector – ECC is recalculated
If there is mismatch in stored and calculated value then data area is corrupted.
Low level formatting is done at factory.
2. Logical formatting or “making a file system”.
After disk is partitioned, logical formatting used
Operating system stores the initial file system data structures onto the disk.
Boot Block:
The system requires an initial program to begin its running.
Example: when the computer system is powered up or rebooted, it needs a program
This program should be very simple.
Problem-solving check is done first
Stage 0 boot program is executed
Boot program reads the first sector form the boot device into main memory.
Boot sector is the first sector of the boot device and contains stage 1 boot program.
May be boot sector will not contain a boot program.
1
PC booting from hard disk, the boot sector also contains a partition table
The code in the boor ROM instructs the disk controller to read the boot blocks into memory and
then starts executing that code.
Full boot strap program is more sophisticated than the bootstrap loader in the boot ROM.
Bad blocks:
Data that resided on the bad blocks usually are lost.
The controller maintains a list of bad blocks on the disk.
The list is initialized during the low level format at the factory, and is updated over the life of the
disk.
Low level formatting also sets aside spare sectors not visible to the operating system.
The controller can be told to replace each bad sector logically with one of the spare sectors.
This scheme is known as sector sparing or forwarding
A typical bad sector transaction might be as follows;
The OS tries to read logical block 90
The controller calculates the ECC and finds that the sector is bad. It reports this finding to the OS
The next time that the system is rebooted, a special command is run to tell the SCSI controller to
replace the bad sector with a spare
After that whether the system requests the logical block 90, the request is translated into the
replacement sectors address by the controller.
___________________________________________________________________________
2
Disk Scheduling
1. The operating system is responsible for using hardware efficiently — for the disk drives,
this means having a fast access time and disk bandwidth.
2. Access time has two major components
Seek time is the time for the disk are to move the heads to the cylinder containing the
desired sector.
Rotational latency is the additional time waiting for the disk to rotate the desired sector
to the disk head.
3. Minimize seek time
4. Seek time seek distance
5. Disk bandwidth is the total number of bytes transferred, divided by the total time between
the first request for service and the completion of the last transfer.
6. Several algorithms exist to schedule the servicing of disk I/O requests.
7. We illustrate them with a request queue (0-199).
Example: 98, 183, 37, 122, 14, 124, 65, 67. Head pointer 53
FCFS
Illustration shows total head movement of 640 cylinders.
SSTF
1. Selects the request with the minimum seek time from the current head position.
2. SSTF scheduling is a form of SJF scheduling; may cause starvation of some requests.
3
3. Illustration shows total head movement of 236 cylinders.
SCA
N
1. The disk arm starts at one end of the disk, and moves toward the other end, servicing requests
until it gets to the other end of the disk, where the head movement is reversed and servicing
continues.
2. Sometimes called the elevator algorithm.
3. Illustration shows total head movement of 208 cylinders.
4
C-SCAN
1. Provides a more uniform wait time than SCAN.
2. The head moves from one end of the disk to the other. servicing requests as it goes. When it
reaches the other end, however, it immediately returns to the beginning of the disk, without
servicing any requests on the return trip.
3. Treats the cylinders as a circular list that wraps around from the last cylinder to the first one.
C-LOOK
1. Version of C-SCAN
2. Arm only goes as far as the last request in each direction, then reverses direction immediately,
without first going all the way to the end of the disk.
5
Selecting a Disk-Scheduling Algorithm
1. SSTF is common and has a natural appeal
2. SCAN and C-SCAN perform better for systems that place a heavy load on the disk.
3. Performance depends on the number and types of requests.
4. Requests for disk service can be influenced by the file-allocation method.
5. The disk-scheduling algorithm should be written as a separate module of the operating system,
allowing it to be replaced with a different algorithm if necessary.
6. Either SSTF or LOOK is a reasonable choice for the default algorithm.
___________________________________________________________________________
File Concepts:
Computers can store information on several different storage medium, such as magnetic disks,
magnetic tapes, and optical disks.
Files are non-volatile, so the contents are determined through power failures and system reboots. A
file is a named collection of related information that is recorded on secondary storage.
Data files may be numeric, alphabetic, alphanumeric, or binary.
Files may be free form, such as text files, or may be formatted tightly.
A file has a certain defined structure according to its type.
A text file is a sequence of characters arranged into lines.
A source fileis a sequence of subroutines and functions.
Anobject file is a sequence of bytes given into blocks understandable by the system linker.
An executable file is a series of code sections that the loader can bring into memory and
execute.
File Attributes:
It varies from one operating system to another. The common file attributes are;
Name: The symbolic file name is the only information kept in human readable form.
Identifier: This unique tag, usually a number identifies the file within the file system; it is
the non-human readable name for the file.
Type: This information is needed for those systems that support different types.
Location: This information is a pointer to a device and to the location of the file on the
device.
6
Size: The current size of the file and the maximum allowed size are included in this
attribute.
Protection: Access control information determines who can do reading, writing, executing
and so on.
Time, date, and user identification: This information may be kept for creation, last
modification, and last use. These data are useful for protection, security and usage
monitoring.
File Operations:
Generally files exist to store information and allow it to be retrieval later.
Many systems provide different operations to allow storage and retrieval.
There are many system calls relating to files. They are:
Creating a file:
The two steps in creating file are
1. Space in system file must be found for the file.
2. An entry for the new file must be made in the directory.
The directory entry records the name of the file and the location in the file system, and
possibly other information.
Writing a file:
To write we specify both the name of the file and the information to be written to the file.
Given the name of the file the system reaches the directory to find the location of the file.
The system must keep the write pointer to the location in the file where the next write is to
take place. The write pointer must be update whenever the write occurs.
Reading a file:
To read a file, system call specifies the name of the file and where the next block of the file
should be put. The system needs to keep a read pointer to the location in the file where the
next read is to take place. Once the read has taken place the read pointer is updated.
Repositioning within a file: The directory is searched for the appropriate entry, and the
current-file position is set to a given value. Repositioning within a file does not need to
involve any actual I/O. This file operation is also known as a file-seek.
7
Deleting a file: To delete a file, we search the directory for the named file. Having found
the associated directory entry, we release all file space so that it can be reused by other files,
and erases the directory entry.
Truncating a file: The user may want to erase the contents of a file but keep its attributes.
The attributes remain unchanged except for the file length which is reset to length zero and
its file space is released.
File Types:
A common technique for implementing file types is to include the type as part of the file name.
The name is split into two parts a name and an extension, usually separated by a period
character. The system uses the extension to indicate the type of the file and the type of
operations that can be done on that file. Only files with .com, .exe. .bat extensions can be
executed.
File type Extension Function
Executable Exe, com, bin Read to run machine language program
Object obj Compiled machine language
Source code C, java pas Source code in various language
Batch Bat Commands to command interpreter
Text Txt, doc Textual data, documents
Word processor wp, tex, doc Various word processor formats
Library Lib, dll Libraries of routines for programmers
Multimedia Mpeg, mov, rm Binary file containing audio or A/V
information
8
Access Methods:
Files store information. When it is used, this information must be accessed and read into
computer memory. The information in the file can be accessed in several ways.
The Pile
Sequential Access
Direct Access
Indexed Access
1. The pile:
It is defined as an arrangement of record in a sequence in which they arrive.
Each record consists of one burst of data.
Each field in these records should be self-describing.
The length of each field is indicated by delimiters known as default.
The pile files are used when the data are not a easy to organize.
When the stored data varies in size & structure then this arrangement is best.
2. Sequential Access:
The simplest access method is sequential access.
Information in the file is processed in order, one record after the other.
The bulk of the operations on a file reads and writes.
A read operation reads the next portion of the file and automatically advances a file pointer,
which tracks the I/O location.
A write appends to the end of the file and advances to the end of the newly written
material( end of file). Sequential access is based on a tape model of a file.
9
3. Direct Access:
Another method isdirect access.
A file is made up of fixed length logical records that allow programs to read and write
records rapidly in no particular order.
The direct access method is based on a disk model of a file, since disks allow random
access to any file block.
A direct access file allows random blocks to be read or written.
It is viewed as numbered orders of blocks or records.
Simple example is an airline reservation system, the information about a particular flight
in the block identified by the flight number. Thus the number of available seats for flight
713 is stored in block 713 of the reservation file.
For direct access method, the file operations must be modified to include the block number
as a parameter.
Thus read n, where n is the block number rather than read next, and write n rather than write
next.
And to add an operation position file to n, where n is the block number.Then to effects a
read n, we would position to n and then read next.
The block number is provided by the user is called a relative block number.
It is the index to the beginning of the file. The first relative block of the file is 0; the next is
1 and so on.
But the actual absolute disk address of the block may be 14703 for the first block and 3192
for the second.
Not all operating systems support sequential and direct access for files.
Some allow sequential and others allow direct access.
But is easy to implement sequential access on direct access, using a variable cp that defines
the current position.
10
4. Other access methods:
Other access methods can be built on top of direct access method.
The index is like an index in the book which contains pointers to the various blocks.
To find the record in the file, we first search the index, and then use the pointer to access the
file directly and to find the desire record.
With large files, the index file itself may become too large to be kept in memory.
One solution is to create an index for the index file.
The primary index file would contain pointers to secondary index files, which would point
to the actual data items.
11
Directory Structure:
The directory contains information about the files, including attributes, location and ownership.
Data must be organized on the disks; this can be done in two parts:
Disks are split into one or more partitions, also known as minidisks orvolumes.
Each disk holds atleast one partition, which is low level structure in which files and directories
reside.
Partitions are also treated as separate storage devices. For this reason partitions are thought to be
virtual disks.
Each partition has information about files within it.
This data & information is provided in entries in a device directory or volume table of contents.
The device directory records information such as:
Name
Location
size
type
12
List directory: We need to be able to list the files in a directory and the contents of the
directory entry for each file in the list.
Rename a file: Because the name of a file represents its contents to its users, the name must
be changeable when the contents or use of the file changes. Renaming also allow its
position within the directory structure to be changed.
Types of Directory:
1. Single-Level Directory
The singlet level directory structure is the simple directory structure.
All files are contained in the same directory, which is easy to implement and understand.
Limitations:
No two files can have the same name.
Because most environment contain a large number of files, many of which the same name,
this type of directory is rarely implemented.
2. Two-Level Directory
To avoid the difficulty caused by different users choosing the same file name for their
own files, the next step up is giving each user a private directory.
Here the names chosen by one user do not interfere with manes chosen by a different user.
And there is no problem caused by the same name occurring in two or more directories.
13
Each user has own user file directory (UFD).
When a user refers to a particular file, only his own UFD is searched.
Different users may have files with the same name, as long as all the file names within each
UFD are unique.
14
Path names can be of two types:
Absolute path name: begins at the root and follows a path down to the specified file, giving
the directory names on the path.
Relative path name: defines a path from the current directory.
Ms-Dos will not delete a directory unless it is empty. For deleting a directory, two
approaches can be taken
To delete a directory the user must first delete all the files in that directory.
In UNIX, rm command is used with some option for deleting directory.
When a request is made to delete a directory, all that directory’s files and subdirectories are
also to be deleted.
In tree structure directory system, users can access their files in addition to others files.
15
Shared files or directories are implemented in several ways.
A link is effectively a pointer to another file or subdirectory.
Example, a link may be implemented as an absolute or relative path name.
An acyclic graph structure is more flexible than is a simple tree; but sometimes it is more
complex.
16
File System Mounting:
The Operating System gives the ability to mount (support) multiple file systems.
Mounting combines multiple file systems into one namespace.
The namespace is set to be files that can be identified by a single file system.
Mounting Procedure: It is a direct method.The OS gives
The name of device
Location within the file structure at which to attach the file system.
Mount Point:
It is an empty directory at which the mounted file system will be attached.
Example: in UNIX, the file system consisting of users home directories is mounted as/home.
Then a directory name is mounted to access the directory structure within that file system.
It gives as /home/Jane
Also, mounting that file system under /users gives the path name as
/users/Jane
This is the purpose of reaching the same directory.
Next, the OS checks if the device is holding a valid file system or not.
This is done by requesting the device driver.
To read the device directory
To check whether the directory has the excepted format.
At last, the OS tells in its directory structure that a file system is mounted at the particular mouse
point. Example: Let the file system be
17
This is available at /devi/xyz. Here, at this stage, only the files on the existing file system can be
accessed. The effect of mounting of the partition residing on /devi/xyz over /usern are given here
______________________________________________________________________________
Allocation Methods:
Files are normally stored on the disks, so the main problem is how to allocate space to these files.
So that disk space is utilized effectively and files can be access and quickly.
The three major methods of allocating disk space are in wide use:
Contiguous
Linked
Indexed
1. Contiguous Allocation Methods:
In this allocation method each file occupies a set of contiguous blocks on the disk.
For example: a disk consisting of 1kb blocks.
A 100kb file would be allocated consecutive blocks with 2kb block; it would be allocated 50
consecutives blocks.
18
In this above figure, the right hand side part is the file allocating table, it consisting of a
single entry for each file.
It shows the file name starting block of the file and size of the file.
For Example:
This method is best suited for sequential files.
The main problem in this, it is difficult to find contiguous free blocks in the disk.
Another problem is external fragmentation; it means some free blocks could happen
between two files.
Advantages:
It provide good performance
Easy to retrieve single block.
It supports variable size partition.
2. Linked Allocation Method:
We can avoid the external fragmentation; in this scheme and also it is easy to locate the
files, because allocation is on an individual block basis.
Each block contains a pointer to the next free block in the chain.
Here also the file allocation table consisting of a single entry for each file.
Using this method any free block can be added to a chain very easily.
There is a link between one block to another block that why it is said into be linked
allocation.
19
Advantages:
Avoid the external fragmentation and compaction
It is suited for sequential file
Pre-allocation is not required
Disadvantages:
The pointer itself occupies some memory with in the block.
It takes much accessing time.
It cannot support direct access
Files are only access sequential files.
3. Grouped or Indexed Allocation:
We can overcome the problem using these methods which were faced in the previous
method. In this method the file allocation table contains a single entry for a each file.
The entry consisting of one index block, the index block having pointer to the other
blocks, which were occupied by the particular file consider in figure.
For Example:
The bubble sort c is a file, the entry for the file in the file allocation table’s points to be
indexed block.
The index block consisting of pointers to the other block.
Which were occupied by the particular file?
In this figure 9.16,1,10,25 there are the blocks occupied by the bubble sort 19.
20
Advantages:
It supports sequential and direct access.
No external fragmentation
Faster than other two methods
It supports fixed and variable sixe block.
Disadvantage:
It does suffer wasted space.
Pointer overhead is generally greater.
______________________________________________________________________________
1. Bit vector:
It is a collection of bits, in which each block is represented by 1 bit.
If the block id free, the bit is 0.
If the block is allocated, the bit is 1.
For Example:
Consider a disk where blocks 2, 5, 8, 16, 20, 26 are free, the free space bit vector would be
10110110111111101110111110
2 5 8 16 20 26
21
2. Chain free points or linked free space:
Another approach is to link all the free space blocks, together keeping a pointer to the 1 st
free space.
This blocks contains a pointer to the next free disk block and so on.
In our example;
We would keep a pointer to block 2 as the 1st free block 2 would contain a pointer to block
3, which would point to block 4, which would block to point to 5 and so on.
3. Counting:
It keeps the address of the 1st free block and the number n of the free contiguous blocks that
follow the 1st block.
Each entry in the free space list then consists of s disk address and a count.
4. Grouping:
It stores the addresses of n free blocks in the 1st free block.
The 1st n – 1 of these blocks are actually free.
The last block contains the address of another of n free block.
Addresses of a large number of free blocks can be found quickly.
______________________________________________________________________________
22
File System Implementation:
A file system organizes files and manages access to data.
The file system is concerned mainly with managing secondary storage space, particularly disk
storage.
But it can access file data stored on other media.
Overview:
To implement a file system, many on disk and in memory structures are used.
On disk, the file system many have information about
How to boot an operating system
Total number of blocks
Free blocks count and their location
Directory structure
Individual files
On disk Structures:
1. Boot control block:
This holds the information required by the system to boot an operating system from that
partition.
If there is no operating system in the disk then this block can be empty.
This is the first block of partition.
It is said to be boot block.
2. Partition Control Block:
This consists of Partition Details. They are
Number of blocks in the partition
Free block count
Size of the blocks
Free FCB count
Free Block Pointer
FCB pointers
It is known as super block in UFS and master tile table in NTFS.
3. Directory Structure:
The Files are arranged by using the directory structure.
23
4. File Control Block:
It has more details. They are
File Permissions
Ownership
Location of data blocks
In memory Information:
By using caching, in both cases of file system management and performance improvement, the in
memory information is used.
In memory partition table:
Every mounted partition information is kept inside in this table.
In memory Directory Structure:
The directory information about recently accessed directories are stored in this structure.
24
This is referred to as a file descriptor in UNIX systems and file handle in Windows 2000.
Root Partition:
It contains the operating system kernel and potentially other system files, is mounted at boot time.
Other partitions can be mounted at boot or manually mounted based on the OS.
As a successful mount operation, the OS checks that the device contains a valid file system.
If the format is invalid then the partition must have its consistency checked and possibly corrected.
So, at last the OS notes in its in memory mount table structure that a file system is mounted and the
type of the file system.
25
Virtual File Systems:
The file system implementation has three major layers:
26
Directory Implementation:
Generally the selection of directory allocation and management algorithms has a effect on
Performance
Efficiency
Reliability of the file system
1. Linear List:
It is uses to implement a directory with pointers to the data blocks.
A linear search is needed for to find a particular entry.
Advantages:
It is simple to Program
Insertion:
When a new file is to be created, it must confirm that any existing file does not hold the same name.
Then a new entry is added at the end of directory.
Deletion of a File:
A directory for the named file is found and then the relevant memory space allocates to that file is
releases.
Ways to reuse the directory:
The entry is specified as unused
The entry may be attached to a list of free directory entries.
Within the freed location, the last entry is the directory is copied.
Disadvantages:
There is a linear Search to find a file.
Normally the directory information is used often. But there is slow access to the information.
Sorted List:
It permits the binary search.
This minimizes the average search time.
2. Hash Table:
It is type of data structures which, can be used for a file directory.
Here, a linear list has the directory entries and a hash data structure is also used
27
It takes a value calculated from the file name and its returns a pointer to the file name in the linear
list. So the directory search time is reduced.
Insertion and Deletion are made with some positive for collision.
Collision is occurred when two file names are hashed to a same place.
Disadvantages:
It is size is fixed
The hash function is depending upon the size of hash table.
Example:
Let a hash table consisting of 64 entries:
The hash function converts file name into integers from 0 to 63.
When the user attempts to get 65th file, the directory has table is to maximized to 128 entries.
So, there is a need of hash function which maps the file names to the range from 0 to 127.
Also, it must to rearrange the existing directory entries to shoe their new hash function values.
______________________________________________________________________________
28
I/O Systems:
Overview of I/O Systems:
Categories of I/O Devices are
Storage Devices Or Machine Readable:
It is suitable for communicating with electronic equipment.Such as Disks and Tapes.
Transmission Devices or Communication:
It is suitable with communicating with remote devices.Such as Network Card and Modems.
Human Interface Devices:
It is suitable with communicating with the computer user.Such as Screen, Keyboard and
Mouse.
Difference between I/O Devices:
Data rate:There may be differences of several orders of size (Magnitude) between the data
transfer rates.
Application:Different devices have different use in the system
Complexity of control:A disk is much more complex whereas printer requires simple
control interfaces.
Unit if transfer:Data may be transferred as a stream of bytes or characters or in larger block
Data representation:Different data encoding schemes are used for different devices.
Error Conditions: The nature of errors differs widely from one device to another device.
I/O Hardware:
A device is communicated along with a system by passing the signals through a cable or by air, port
or bus.
A connection point or port is used to communicate the device with the machine.
Example: Serial Port.
Given Below the Figure: Typical Structure of PCI bus:
Bus: If one or more devices use a common set of wires, the connection is called as bus.
PC Bus System: It is used to connect the processor memory subsystem to the fast devices.Here an
expansion bus is used to connect the slow devices like keyboard, serial and parallel ports. With the
SCSI bus, four disks are connected and this is plugged into the SCSI controller.
29
Controller: It is a collection of electronics that can operate a port, bus or a device.
Serial Port Controller: It is a simple device. This is a single chip in the computer that controls the
signals on the wires of the serial port.
SCSI Bus Controller:
This is not like the serial port controller.Because the SCSI protocol is difficult to proceed.
This SCSI bus controller is used as a separate circuit board which plugs into the system.
Memory Mapped I/O: It to control others
Device I/O Port Location on PCs:
30
The I/O port consists of four registers:
Status Register: It has the bits which can be read by the host.
Control Register: This can be used by a host for starting a command or change the device
made.
Data-in Register: It is read by the host to get input.
Data-out Register: It is written by the host to send output.
1. Polling:
The processors inform the operating system of events such as program execution or changes in
devices.A processor can do so by repeatedly requesting the status of each device, a technique called
polling or also called as busy waiting.
Hand shaking:
The interaction between the host and the controller can be done using hand shaking concept.
This can be done the following steps. They are:
i. The busy bit is read by the host repeatedly until is cleared.
ii. The host sets the write bit in the command register and writes a byte into the data out
register.
iii. If the command bit ready is set sets the busy bit.
iv. The controller also reads the command register and it looks the write command.
It reads the data out register to have the byte and it does the I/O to the devices.
v. To represent the I/O is successfully completed, the controller
Clears the command ready bit
Clears the error bit in the status register
Clears the busy bit
This loop is repeated for each byte.
2. Interrupts:
The CPU hardware has a wire called the interrupt request line which is sensed by the CPU at the
end of the execution of every instruction.
When the CPU detects that controller has open a signal on the interrupt request wire, the CPU saves
the current state and jumps to the interrupt- handler routine at a fixed addresses in memory.
31
The interrupt handler defines the reason of the interrupt, performs the necessary processing and
execution a return from interrupt instruction to return the CPU to the execution earlier to the
interrupt.
32
32 – 255 are maskable
The interrupt mechanism is also used to handle wide variety of exceptions, such as dividing by zero,
accessing a protected or non-existent memory address or attempting to execute confidential
instruction from user mode.
In an given below, the following table shows the interrupt vector for Intel Pentium Processor
33
The direct memory access confirmed access to main memory without processor interruption or
support.
Such independence from processor makes this mode of transfer extremely efficient.
DMS Transfer:
The host writes a DMA command block into memory inorder to start the DMA transfer
Actually this block is consisting of
A pointer to the source of transfer
A pointer to the destination
Number of bytes to be transmitted
The CPU writes this command block address to the DMA controller.
The DMA controller keeps the addresses on the bus to do data transfer without getting any help
form the main CPU.
DMA Controller:
It is a standard component in the system and bus mastering I/O boards for the system which has
their own high speed DMA hardware.
Six Step Process to Perform DMA Transfer
34
DMA Request and Acknowledge:
These two are the pair of wires which are used in the handshaking between the DMA controller and
the device controller.
When a word of data is there for data transfer, the device controller keeps a signal on the DMA
request wire.
It makes the DMA controller to seize the memory bus inorder to keep the required address on the
memory address wires.
This is also for placing a signal on the DMA acknowledges wire.
At the time of getting the DMA acknowledge signal by a device controller, it transfers the CPU, the
word of data to memory.
The DMA request signal is also removed.
If the data transfer is wholly completed then the DMA controller interrupts the CPU.
The system performance can be achieved by unloading the data transfer work to a DMA controller.
Direct Virtual Memory Access (DVMA):
It uses virtual addresses which perform virtual to physical memory address translation.
The data transfer is done in-between the two memory mapped devices by the DVMA without
getting any help from the CPU or main memory.
___________________________________________________________________________
35
Application I/O Interface:
I/O management requires that a proper setup is created by an application on a computer system with
an IO device.
An IO operation is a combination of hardware and software instructions.
After the IO command is given in a process, the operating system kernel resolves it and then
communicates with the concerned device driver.
36
Synchronous or Asynchronous:
A synchronous device is one that performs data transfer with predictable response times.An
asynchronous device exhibits irregular or unpredictable response time.
Sharable or dedicated;
A sharable device can be used concurrently by several processes or threads; a dedicated
device cannot.
Speed of operation:
Device speeds range from a few bytes per second to a few gigabytes per second.
read-write, read only, or write only:
Some devices perform both input and output, but others support only one data direction.
Charactertics of IO devices:
37
Libraries layered on top allow line editing
2. Network Devices:
Varying enough from block and character to have own interface
UNIX and Windows NT/9x/2000 include socket interface
Separates network protocol from network operation
Includes select functionality
Approaches vary widely (pipes, FIFOs, streams, queues, mailboxes)
3. Clocks and Timers:
Provide current time, elapsed time, timer
Programmable interval timer used for timings, periodic interrupts
ioctl (on UNIX) covers odd aspects of I/O such as clocks and timers
4. Blocking and Non-Blocking I/O:
Blocking - process suspended until I/O completed
Easy to use and understand
Insufficient for some needs
Non-blocking - I/O call returns as much as available
User interface, data copy (buffered I/O)
Implemented via multi-threading
Returns quickly with count of bytes read or written
Asynchronous - process runs while I/O executes
Difficult to use
I/O subsystem signals process when I/O completed
__________________________________________________________________________
38
This is the innermost layer of the operating system close to the hardware and controlling the actual
hardware.
It is the heart of the operating system.
Kernel I/O subsystem provides following services:
Scheduling
Buffering
Caching
Spooling andDevice reservation
Error Handling
I/O Scheduling:
It is a process in which a good order is found to execute the set of I/O requests.
Generally scheduling
Can increases the overall system performance
Can share the device access fairly below the operation.
May minimize the average waiting time for I/O to complete.
Operating system developers implement scheduling by maintaining a queue of request for each
device.
When an application issues a blocking I/O system call, the request is placed on the queue for that
device.
The I/O scheduler rearranges the order of the queue to improve the overall efficiency and the
average response time.
Buffering:
It is a technique by which the device manager can keep slower I/O devices busy during times when
a process is not demanding I/O operations.
Process
Reasons for Buffering:
1. Speed mismatch in between the producer and consumer of a data stream.
Example:
A file has to be obtained through a modem for storage on the hard disk.
But the modem isA100 times slower than hardBdisk.
i.e... Why a buffer is introduces to have the bytes which come from the modem.
39
Device
Double Buffering:
There are two buffers in the system.
One buffer is for the driver or controller to store data while waiting for it to be retrieved
by higher level of the hierarchy.
Other buffer is to store data from the lower level module
It is also called as buffer swapping
Process
A B
A B
Device
40
2. The second reason for buffering is to adapt between the devices which holds different data
transfer size.
This is mostly used in case of computer networking for the purpose of fragmentation and
reassembly of messages.
So a large message splitted into smaller fragments at the sender side.
Then these are passed through the communication network.
3. Buffering is needed for supporting the copy semantics for application I/O.
A simple strategy for copy semantics is for the write ( ) system call inorder to copy the
application data within the kernel buffer before returning the control to application.
Caching:
To improve the performance, most systems perform caching by placing copies of information that
processes location in faster storage.
Due to the high cost of fast storage, caches can contain only a small portion of the information
contained in slower storage.
Caches can contain only a small portion of the information contained in slower storage.
Spooling and Device reservation:
It is a technique in which an intermediate device like a disk, it is cut in between a process and a low
speed or buffer limited I/O device.
Error Handling:
Generally the device and I/O transfers may fair in many ways.
They are
Transmit reasons: Example: Network becoming overloaded
Permanent reasons: Example: a disk controller becoming effective.
Operating system can frequently compensate effectively for temporary failure.
41