0% found this document useful (0 votes)
117 views10 pages

Allocation Methods

The document discusses different methods for allocating disk blocks to files, including contiguous allocation, linked allocation, and indexed allocation. Contiguous allocation stores files using contiguous disk blocks but can be wasteful of space. Linked allocation links disk blocks anywhere on disk, avoiding waste but hindering random access. Indexed allocation uses an index table to map file blocks, enabling random access without external fragmentation. The document also covers free space management techniques like bit vectors and linked lists.

Uploaded by

Levingsten S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views10 pages

Allocation Methods

The document discusses different methods for allocating disk blocks to files, including contiguous allocation, linked allocation, and indexed allocation. Contiguous allocation stores files using contiguous disk blocks but can be wasteful of space. Linked allocation links disk blocks anywhere on disk, avoiding waste but hindering random access. Indexed allocation uses an index table to map file blocks, enabling random access without external fragmentation. The document also covers free space management techniques like bit vectors and linked lists.

Uploaded by

Levingsten S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Allocation Methods

n An allocation method refers to how disk blocks are


allocated for files:

n Contiguous allocation
n Linked allocation
n Indexed allocation

Operating System Concepts

12.1

Silberschatz, Galvin and Gagne 2002

Contiguous Allocation

n Each file occupies a set of contiguous blocks on the disk.


n Simple only starting location (block #) and length
(number of blocks) are required.

n Random access.
n Wasteful of space (dynamic storage-allocation problem).
n Files cannot grow.

Operating System Concepts

12.2

Silberschatz, Galvin and Gagne 2002

1
1

Contiguous Allocation of Disk Space

Operating System Concepts

12.3

Silberschatz, Galvin and Gagne 2002

Extent-Based Systems
n Many newer file systems (I.e. Veritas File System) use a
modified contiguous allocation scheme.

n Extent-based file systems allocate disk blocks in extents .


n An extent is a contiguous block of disks. Extents are
allocated for file allocation. A file consists of one or more
extents.

Operating System Concepts

12.4

Silberschatz, Galvin and Gagne 2002

2
2

Linked Allocation
n Each file is a linked list of disk blocks: blocks may be
scattered anywhere on the disk.

block

pointer

Operating System Concepts

Silberschatz, Galvin and Gagne 2002

12.5

Linked Allocation (Cont.)

n Simple need only starting address


n Free-space management system no waste of space
n No random access
n Mapping
Q
LA/511
R

Block to be accessed is the Qth block in the linked chain of


blocks representing the file.
Displacement into block = R + 1
File-allocation table (FAT) disk-space allocation used by MS-DOS
and OS/2.

Operating System Concepts

12.6

Silberschatz, Galvin and Gagne 2002

3
3

Linked Allocation

Operating System Concepts

12.7

Silberschatz, Galvin and Gagne 2002

File-Allocation Table

Operating System Concepts

12.8

Silberschatz, Galvin and Gagne 2002

4
4

Indexed Allocation
n Brings all pointers together into the index block.
n Logical view.

index table

Operating System Concepts

12.9

Silberschatz, Galvin and Gagne 2002

Example of Indexed Allocation

Operating System Concepts

12.10

Silberschatz, Galvin and Gagne 2002

5
5

Indexed Allocation (Cont.)

n Need index table


n Random access
n Dynamic access without external fragmentation, but have
overhead of index block.

n Mapping from logical to physical in a file of maximum size


of 256K words and block size of 512 words. We need
only 1 block for index table.
Q
LA/512
R

Q = displacement into index table


R = displacement into block

Operating System Concepts

Silberschatz, Galvin and Gagne 2002

12.11

Indexed Allocation Mapping (Cont.)

n Mapping from logical to physical in a file of unbounded


length (block size of 512 words).

n Linked scheme Link blocks of index table (no limit on


size).
Q1
LA / (512 x 511)
R1

Q 1 = block of index table


R 1 is used as follows:

Q2
R 1 / 512
R2

Q 2 = displacement into block of index table


R 2 displacement into block of file:

Operating System Concepts

12.12

Silberschatz, Galvin and Gagne 2002

6
6

Indexed Allocation Mapping (Cont.)


n T w o - l e v e l i n d e x ( m a x i m u m f i l e s i z e i s 5 1 23 )
Q1
LA / (512 x 512)
R1

Q 1 = displacement into outer-index


R 1 is used as follows:

Q2
R 1 / 512
R2

Q 2 = displacement into block of index table


R 2 displacement into block of file:

Operating System Concepts

Silberschatz, Galvin and Gagne 2002

12.13

Indexed Allocation Mapping (Cont.)

outer-index

index table

Operating System Concepts

12.14

file

Silberschatz, Galvin and Gagne 2002

7
7

Combined Scheme: UNIX (4K bytes per block)

Operating System Concepts

Silberschatz, Galvin and Gagne 2002

12.15

Free-Space Management
n Bit vector

(n b l o c k s )
0

n-1

bit[i ] =

678

0
1

block[i ] free
block[i ]

occupied

Block number calculation


(number of bits per word) *
(number of 0-value words) +
offset of first 1 bit

Operating System Concepts

12.16

Silberschatz, Galvin and Gagne 2002

8
8

Free-Space Management (Cont.)


n Bit map requires extra space. Example:
b l o c k s i z e = 2 12 b y t e s
disk size = 2
n = 2

30

30

/2 12 = 2

bytes (1 gigabyte)
18

bits (or 32K bytes)

n Easy to get contiguous files


n Linked list (free list)
F Cannot get contiguous space easily
F No waste of space

n Grouping
n Counting

Operating System Concepts

12.17

Silberschatz, Galvin and Gagne 2002

Free-Space Management (Cont.)

n Need to protect:
F Pointer to free list
F Bit map
4Must be kept on disk
4 Copy in memory and disk may differ.
4 C a n n o t a l l o w f o r b l o c k [i ] t o h a v e a s i t u a t i o n w h e r e b i t [ i ] =
1 i n m e m o r y a n d b i t [ i] = 0 o n d i s k .

F Solution:
4 Set bit[i] = 1 in disk.
4 A l l o c a t e b l o c k [i ]
4 Set bit[i] = 1 i n m e m o r y

Operating System Concepts

12.18

Silberschatz, Galvin and Gagne 2002

9
9

Linked Free Space List on Disk

Operating System Concepts

12.19

Silberschatz, Galvin and Gagne 2002

Efficiency and Performance


n Efficiency dependent on:
F disk allocation and directory algorithms
F types of data kept in files directory entry

n Performance
F disk cache separate section of main memory for
frequently used blocks

F free-behind and read-ahead techniques to optimize


sequential access

F improve PC performance by dedicating section of memory


as virtual disk, or RAM disk.

Operating System Concepts

12.20

Silberschatz, Galvin and Gagne 2002

10
10

You might also like