0% found this document useful (0 votes)
6 views

Chapter 3

This document discusses operating systems for single-tasking computers. It describes the functions of an operating system, including communicating with users and managing hardware resources. It also covers memory organization, input/output software layers, disk driver operations, and different methods for file storage on disks like sequential allocation, using a file allocation table, and using i-nodes.

Uploaded by

Aadil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Chapter 3

This document discusses operating systems for single-tasking computers. It describes the functions of an operating system, including communicating with users and managing hardware resources. It also covers memory organization, input/output software layers, disk driver operations, and different methods for file storage on disks like sequential allocation, using a file allocation table, and using i-nodes.

Uploaded by

Aadil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Computer Engineering

Chapter 3

Operating systems for single-tasking computers

3.1 What is an Operating System?


The simple answer is that an Operating
System comprises a set of programs which
run continuously while the machine is in
use. Their purpose is to undertake the
‘‘housekeeping’’ of the system.
A n o p e r a t i n g s y s t e m h a s t wo m a i n
functions, shown in Figure 3.1:-
1. To communicate with the users of the
system. It is sometimes said that this
presents the users with a Virtual Machine,
in which the underlying software and
hardware are invisible.
2. To manage the hardware resources of the
system. It therefore handles the allocation
and scheduling of the components of the
total computer.
Fig.3.1 Functions of an Operating System

3.2 Memory organisation for single processes


Every program that is executed requires memory space for three
purposes: Program storage, data storage and stack memory.
Often this is allocated in the order shown in Figure 3.2.
However, the operating system requires memory space, since it
is also a program or suite of programs. There are three possible
arrangements for memory allocation, shown in Figure 3.4:-
(a) The operating system is loaded into the machine (from disk)
every time the computer is switched on, and therefore resides in
RAM. This arrangement was used in the Apple II computer.
(b) The operating system is located in a ROM, and therefore is
immediately available upon powering-up the computer. This is
the principle of the BBC microcomputer.
(c) The operating system is split into two sections: the software
that provides the I/O facilities, and the rest of the operating Fig.3.2 Program memory allocation
system. The I/O drivers reside in ROM, while the main OS is
loaded from disk into RAM upon booting the system.
The last method is the one used by the IBM Personal Computer machines. The I/O routines are
collected into a set of functions known as the BIOS (Basic Input Output System), which is located in
ROM on the motherboard. The operating system (MS-DOS, Windows 95, Windows NT etc) is
loaded from the hard disk whenever the machine is booted. From within the operating system it is
possible to call individual functions in the BIOS, to carry out configuration tasks, disk calls, serial
communication, CRT control and suchlike.

10
Computer Engineering

Fig.3.3 Three ways of providing memory for an OS

3.3 Input/output Software


To understand the total
operation of the I/O
system, it is helpful to
use a ‘‘Layered
Architecture Model’ ’ ,
shown in Figure 3.4. The
User Software consists
of programs which make
calls for I/O operations
to the Device
Independent Software
layer. This provides data
transfer without the user
knowing the details of
the actual device.
Below this are the device
drivers, which are
programs containing all
the device-dependent
Fig.3.4 Input/Output layers
code.
There are two types of
drivers:
1. Drivers which pass bytes to registers in the device controller hardware, and then keep running
continuously. e.g. video drivers
2. Drivers which pass bytes to controller registers and then stop until an interrupt from the controller
restarts the driver. e.g. block transfer from disks. After receipt of data from the controller, the
driver also check the results for errors before passing the data to the next layer up.
The typical activities of the Device-Independent Software are:-
1. Naming devices - mapping of correct device to its driver.
2. Protection - preventing unauthorised access.
3. Making uniform block sizes regardless of type of device.

11
Computer Engineering

3.4 Disk Driver Software


3.4.1 Operations of the disk driver
The various activities carried out at this level of the I/O software are:-
1. Setting up the Direct Memory Access registers.
2. Starting and stopping the drive motor.
3. Moving the drive arm to the required cylinder.
4. Reading or writing data.
5. Starting the watchdog timer, to enable timeout facilities.
3.4.2 Disk arm scheduling algorithms
During the running of a program, the disk driver will receive a stream of requests for access to
different blocks on the disk. The slowest part of the mechanical operation is the moving of the heads
to the required cylinder (known as ‘‘seeking’ ’ ). Therefore it may benefit the total efficiency of the disk
access if the driver stores the requests for cylinders and executes an intelligent algorithm for servicing
these requests.
Three commonly used algorithms are described below, and illustrated in Figure 3.5., for a situation
where the order of cylinder requests is: 8, 2, 23, 5, 14, 9, 25

Fig.3.5 Disk scheduling algorithms

12
Computer Engineering

(a) First-Come-First-Served algorithm


In this case, the driver services each request in the order in which it is received. This results in a large
inefficient movement of heads.
(b) Shortest Seek First algorithm
This causes the driver to keep a list of current disk requests at any time, and then make the shortest
movement of the head each time. The disadvantage stems from the fact that new requests are being
received constantly. The result is that blocks at the edge of the disk have to wait a long time.
(c) Elevator Algorithm
The disk driver faces the same problem as a lift in a tall building. First-Come-First-Served is
inefficient, since it passes waiting people. Shortest Seek First neglects those at the top of the building.
The answer for the lift is to go UP until there are no more requests above, then DOWN until no more
requests below. When applied to the disk, the algorithm causes the head to move in one direction (in
or out) until there are no more cylinders in the current list, then reverse direction to service all
requests in that direction.

3.5 File storage on disk


3.5.1 Block storage of data
A file is stored as a set of blocks (sectors) of data on the disk. Each block is the same size throughout
a particular disk, and is transferred as a unit to and from the memory as required by the CPU. Since
programs are constantly reading and writing new files (or updating existing files), a system of
allocation and reference is needed.
Three main ways of implementing this are used in computer systems.
3.5.2 Sequential allocation
The file is stored on the disk as consecutive blocks of data, as shown in Figure 3.6. The problem
occurs when a file wants to grow (as with the output from an editor ). If a file is too large for its
current space, it is written into the empty blocks after the last file. This leaves large ‘‘holes’ ’ on the
disk of unused blocks. The user needs to recompact the disk frequently to fill up the wasted space.
This system was used on the BBC Disk Filing System.

Fig.3.6 File storage in sequential blocks

3.5.3 Use of File Allocation Table (FAT)


This method keeps two tables in the first few blocks on the disk. One is a Directory Table, showing
each filename, the start block of each file’ s data, and the number of blocks used by the file. The other
is the File Allocation Table, which keeps entries, one for each block. These entries are ‘‘pointers’ ’ to
the next block in a file, and usually contain a block number. The last block in a file contains the entry
EOF (End of File), and blocks not yet allocated are marked as FREE. Blocks known to be faulty are
marked as BAD.
Figure 3.7 illustrates the concept, where three files ‘‘FileA’ ’ , ‘‘FileB’ ’ and ‘‘FileC’ ’ are stored in
random blocks. By following the pointers from the start block, we can deduce that the files are stored
in the following block order:-
FileA: 6 8 4 2

13
Computer Engineering

FileB: 5 9 12
FileC: 10 3 13
By using the FAT concept the disk driver can allocate blocks randomly over the disk area, and there is

Fig.3.7 Example of Directory Table and File Allocation Table

no problem of ‘‘holes’ ’ developing. This system is used in the MSDOS operating system.
However the disadvantage of using a FAT is that its size grows with disk size. Consider the evolution
of IBM disks systems. Originally, IBM chose 12-bit block numbers (to allow for future growth), and
block sizes of 1 kbyte (each occupying 2 sectors).
1. 320 kbyte floppy disks needed 320 entries. Therefore 480 bytes required for the FAT
2. 360 kbyte floppy disks needed 360 entries. Therefore 540 bytes required for the FAT (needed 2
sectors)
3. Greater than 4096 kbytes needed more that 12-bit block numbers.
4. A 64 Mbyte hard-disk would require 128 kbytes for the FAT alone.
Therefore the FAT approach is unsuitable for very large disk systems.

3.5.4 Use of i-nodes


This system, which was developed for UNIX, keeps block lists for different files in different places. A
small table, called an i-node, is kept on disk for each file. As shown in Figure 3.8, it contains space
for 10 file block numbers. If the length of the file exceeds 10 blocks then the ‘‘single indirect’ ’ entry
contains the number of a new block which stores a further 256 block numbers.
If the file exceeds 266 blocks, then ‘‘double indirect’ ’ contains the number of a block, which itself
contains the numbers of 256 blocks each containing 265 block numbers. Thus files of 65802 blocks
can be stored.
If this is insufficient, then the ‘‘triple indirect’ ’ entry can be utilised.
The main advantage of the i-node method is that space required for storage of file information is
small.

14
Computer Engineering

Fig.3.8 Structure of an i-node and its pointers

3.6 Questions on the chapter


1. The Directory Table and the FAT for a particular computer disk system contain the following values:-
Directory Table File Allocation Table
Filename Start Block Block No. Pointer Value
A 5 0 FREE
B 2 1 EOF
C 3 2 8
D 11 3 EOF
4 7
5 12
6 1
7 10
8 6
9 EOF
10 9
11 4
12 13
13 EOF
14 FREE
For each of the files A, B, C, D determine the sequence of blocks in which the file is stored.

15
Computer Engineering

2. Disk requests come into a disk driver for cylinders in the following order:
2, 8, 39, 6, 22, 14, 34, 35, 12, 5
If the arm takes 11 ms to move from one cylinder to the next, and is initially at the cylinder 20,
calculate the total time to service all the requests for:
(a) the First Come First Served algorithm
(b) the Shortest Seek First algorithm
(c) the Elevator algorithm, with the arm initially moving upwards.

16

You might also like