Page 230 - DCAP103_Principle of operating system
P. 230
Unit 6: File Management
6.9.3 Protection Based on an OS Mode Notes
Most processor supports at least two modes of operations—1. User mode and 2. Kernel mode.
The reason for using two modes should be clear. It is necessary to protect the OS and the key
OS table such as process control blocks, from interference by user programs in kernel mode.
This level of control is not necessary for user mode.
6.10 Allocation Methods
The direct-access nature of disks allows us exibility in the implementation of files. In almost
every case, many files are stored on the same disk. The main problem is how to allocate space
to these files so that disk space is utilized effectively and files can be accessed quickly. Three
major methods of allocating disk space are in wide use—contiguous, linked, and indexed. Each
method has advantages and disadvantages. Some systems (such as Data General’s RDOS for
its Nova line of computers) support all three. More commonly, a system uses one method for
all files within a file system type.
6.10.1 Contiguous Allocation
Contiguous allocation requires that each file occupy a set of contiguous blockson the disk. Disk
addresses dene a linear ordering on the disk. With thisordering, assuming that only one job is
accessing the disk, accessing block b + 1 after block b normally requires no head movement.
When head movementis needed (from the last sector of one cylinder to the last sector of the
next cylinder), the head need only move from one track to the next. Thus, the number of disk
seeks required for accessing contiguously allocated files is minimal, as is seek time when a seek
is finally needed. The IBM VM/CMS operating system uses contiguous allocation because it
provides such good performance. Contiguous allocation of a file is defined by the disk address
and length (inblock units) of the first block. If the file is n blocks long and starts at location b,
then it occupies blocks b, b + 1, b + 2, ..., b + n – 1. The directory entry for each file indicates
the address of the starting block and the length of the area allocated for this file.
Figure 6.7: Contiguous Allocation of Disk Space
Directory
count File Start Length
0 1 2 3 count 0 2
tr 14 3
4 5 6 7 mail 19 6
list 28 4
8 9 10 11
tr f 6 2
12 13 14 15
16 17 18 19
mail
20 21 22 23
24 25 26 27
list
28 29 30 31
Accessing a file that has been allocated contiguously is easy. For sequential access, the file
system remembers the disk address of the last block referenced and, when necessary, reads
the next block. For direct access to block i of a file that starts at block b, we can immediately
access block b + i. Thus, both sequential and direct access can be supported by contiguous
LOVELY PROFESSIONAL UNIVERSITY 223