Module 3
Module 3
3. Interrupt Mode
Let us begin with a simple illustration to explain the basic rationale behind interrupt
mode of data transfer. Suppose a program needs input from a device which communicates using
interrupt. Even with the present-day technology the devices are one thousand or more times
slower than the processor. So if the program waits on the input device it would cycle through
many processor cycles just waiting for the input device to be ready to communicate. This is
where the interrupt mode of communication scores.
To begin with, a program may initiate IO request and advance without suspending its operation.
At the time when the device is actually ready to establish an IO, the device raises an interrupt to
seek communication. Immediately the program execution is suspended temporarily and current
state of the process is stored. The control is passed on to an interrupt service routine (which may
be specific to the device) to perform the desired input. Subsequently, the suspended process
context is restored to resume the program from the point of its suspension.
Interrupt processing may happen in the following contexts:
Internal Interrupt: The source of interrupt may be a memory resident process or a
function from within the processor. We regard such an interrupt as an internal interrupt.
A processor malfunction results in an internal interrupt. An attempt to divide by zero or
execute an illegal or non-existent instruction code results in an internal interrupt as well.
A malfunction arising from a division by zero is called a trap. Internal interrupt may be
caused by a timer as well. This may be because either the allocated processor time slice
to a process has elapsed or for some
reason the process needs to be pre-empted. Note that an RTOS may pre-empt a running process
by using an interrupt to ensure that the stipulated response time required is met. This would also
be a case of internal interrupt.
External Interrupt: If the source of interrupt in not internal, i.e. it is other than a process
or processor related event then it is an external interrupt. This may be caused by a device
which is seeking attention of a processor. As indicated earlier, a program may seek an IO
and issue an IO command but proceed. After a while, the device from which IO was
sought is ready to communicate. In that case the device may raise an interrupt. This
would be a case of an external interrupt.
Software Interrupt: Most OSs offer two modes of operation, the user mode and the
system mode. Whenever a user program makes a system call, be it for IO or a special
service, the operation must have a transition from user mode to system mode. An
interrupt is raised to effect this transition from user to system mode of operation. Such an
interrupt is called a software interrupt.
Let us now recap the above mode of transfer within a logical framework with a step-bystep
description. This procedure can be understood in the context of Figure 3.4. In the figure a few
lines do not have an accompanying label. However, by following the numbered sequence and its
corresponding label, one can find the nature of the operations considered.
The procedure can be understood by following the description given below:
We shall assume that we have a program P which needs to communicate with a device
D and get a chunk of data D to be finally stored starting in address A. The reader should follow
through the steps by correlating the numbers in Figure 3.4.
1. The program makes a DMA set-up request.
2. The program deposits the address value A and the data count D.the program also indicates the
virtual memory address of the data on disk.
3. The DMA controller records the receipt of relevant information and acknowledges the DMA
complete.
4. The device communicates the data to the controller buffer.
5. The controller grabs the address bus and data bus to store the data, one word at a
time.
6. The data count is decremented.
7. The above cycle is repeated till the desired data transfer is accomplished. At
which time a DMA data transfer complete signal is sent to the process.
The network-oriented traffic (between machines) may be handled in DMA mode. This is
so because the network cards are often DMA enabled. Besides, the network traffic usually
corresponds to getting information from a disk file at both the ends. Also, because network
traffic is in bursts, i.e. there are short intervals of large data transfers. DMA is
the most preferred mode of communication to support network traffic.
1. Device Drivers
At the lowest level, device drivers communicate directly with peripheral devices or their
controllers or channels. A device driver is responsible for starting I/O operations on a device and
processing the completion of an I/O request. For file operations, the typical devices controlled
are disk and tape drives. Device drivers are usually considered to be part of the operating system.
2. Basic File System
The next level is referred to as the basic file system, or the physical I/O level. This is the
primary interface with the environment outside of the computer system. It deals with blocks of
data that are exchanged with disk or tape systems. Thus, it is concerned with the placement of
those blocks on the secondary storage device and on the buffering of those blocks in main
memory. It does not understand the contents of the data
or the structure of the files involved. The basic file system is often considered part of the
operating system.
3. Basic I/O Supervisor
The basic I/O supervisor is responsible for all file I/O initiation and termination. At this level,
control structures are maintained that deal with device I/O, scheduling, and file status. The basic
I/O supervisor selects the device on which file I/O is to be performed, based on the particular file
selected. It is also concerned with scheduling disk and
tape accesses to optimize performance. I/O buffers are assigned and secondary memory is
allocated at this level. The basic I/O supervisor is part of the operating system.
4. Logical I/O
Logical I/O enables users and applications to access records. Thus, whereas the basic file system
deals with blocks of data, the logical I/O module deals with file records. Logical I/O provides a
general-purpose record I/O capability and maintains basic data about files. The level of the file
system closest to the user is often termed the access method. It provides a standard interface
between applications and the file systems and devices that hold the data. Different access
methods reflect different file structures and different ways of accessing and processing the data.
Some of the most common access methods are shown in Figure 01, and they have been described
in the previous unit.
Elements of File Management
Another way of viewing the functions of a file system is shown in Figure 03. Let us follow this
diagram from left to right. Users and application programs interact with the file system by means
of commands for creating and deleting files and for performing operations on files. Before
performing any operation, the file system must identify and locate the selected file. This requires
the use of some sort of directory that serves to describe the location of all files, plus their
attributes. In addition, most shared systems enforce user access control:
Only authorised users are allowed to access particular files in particular
ways.
The basic operations that a user or application may perform on a file are performed at the record
level. The user or application views the file as having some structure that organises the records,
such as a sequential structure (e.g., personnel records are stored alphabetically by last name).
Thus, to translate user commands into specific file manipulation commands, the access method
appropriate to this file structure must be employed. Whereas users and applications are
concerned with records or fields, I/O is done on a block basis. Thus, the records or fields of a file
must be organised as a sequence of blocks for output and unblocked after input. To support block
I/O of files, several functions are needed.
The secondary storage must be managed. This involves allocating files to free blocks on
secondary storage and managing free storage so as to know what blocks are available for new
files and growth in existing files. In addition, individual block I/O requests must be scheduled.
Both disk scheduling and file allocation are concerned with optimising
performance. As might be expected, these functions therefore need to be considered together.
Furthermore, the optimisation will depend on the structure of the files and the access patterns.
Accordingly, developing an optimum file management system from the point of view of
performance is an exceedingly complicated task.
Figure 3 suggests a division between what might be considered the concerns of the file
management system as a separate system utility and the concerns of the operating system, with
the point of intersection being record processing. This division is arbitrary; various approaches
are taken in various systems
Operations Supported by File Management System
Users and applications wish to make use of files. Typical operations that must be supported
include the following:
1. Retrieve _All
Retrieve all the records of a file. This will be required for an application that must process all of
the information in the file at one time. For example, an application that produces a summary of
the information in the file would need to retrieve all records. This operation is often equated with
the term sequential processing, because all of the records
are accessed in sequence.
2. Retrieve _One
This requires the retrieval of just a single record. Interactive, transaction-oriented applications
need this operation.
3. Retrieve _Next
This requires the retrieval of the record that is “next” in some logical sequence to the most
recently retrieved record. Some interactive applications, such as filling in forms, may require
such an operation. A program that is performing a search may also use this operation.
4. Retrieve _Previous
Similar to Retrieve_Next, but in this case the record that is “previous” to the currently accessed
record is retrieved.
5. Insert _One
Insert a new record into the file. It may be necessary that the new record fit into a particular
position to preserve a sequencing of the file.
6. Delete_One
Delete an existing record. Certain linkages or other data structures may need to be updated to
preserve the sequencing of the file.
7. Update_One
Retrieve a record, update one or more of its fields, and rewrite the updated record back into the
file. Again, it may be necessary to preserve sequencing with this operation. If the length of the
record has changed, the update operation is generally more difficult than if the length is
preserved.
8. Retrieve_Few
Retrieve a number of records. For example, an application or user may wish to retrieve all
records that satisfy a certain set of criteria.
The nature of the operations that are most commonly performed on a file will influence the way
the file is organized, as discussed under file organisation, which in the next unit. It should be
noted that not all file systems exhibit the sort of structure discussed in this subsection. On UNIX
and UNIX-like systems, the basic file structure is just a stream of
bytes. For example, a C program is stored as a file but does not have physical fields, records, and
so on.