Title: Lecture 24 File-System III
1Lecture 24File-System III
- File System Implementation
2Secondary Storage Management
- Space must be allocated to files
- Must keep track of the space available for
allocation - Space is allocated as one or more contiguous
units or portions - From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
3Preallocation
- Need the maximum size for the file at the time of
creation - Difficult to reliably estimate the maximum
potential size of the file - Tend to overestimated file size so as not to run
out of space - From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
4Portion Size
- Contiguity of space increases performance
- Large number of small portions increases the size
of tables needed - Fixed-size simplifies the reallocation of space
- Variable-size minimizes waste of unused storage
- From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
5Methods of File Allocation
- Contiguous allocation
- single set of blocks is allocated to a file at
the time of creation - only a single entry in the file allocation table
- starting block and length of the file
- Fragmentation will occur
- Will become difficult to find contiguous blocks
of sufficient length - From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
6Contiguous File Allocation
File Allocation Table
FileA
File Name
Start Block
Length
0
1
2
3
4
FileA
2
3
FileB
9
5
5
6
7
8
9
FileC
18
8
FileB
FileD
30
2
10
11
12
13
14
FileE
26
3
15
16
17
18
19
FileC
20
21
22
23
24
FileE
25
26
27
28
29
FileD
30
31
32
33
34
From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
7Methods of File Allocation
- Chained allocation
- allocation on basis of individual block
- each block contains a pointer to the next block
in the chain - only single entry in the file allocation table
- starting block and length of file
- No fragmentation
- Any free block can be added to the chain
- No accommodation of the principle of locality
- From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
8Chained File Allocation
File Allocation Table
FileB
File Name
Start Block
Length
0
1
2
3
4
...
...
...
FileB
5
1
5
6
7
8
9
...
...
...
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
9Methods of File Allocation
- Indexed allocation
- file allocation table contains a separate
one-level index for each file - the index has one entry for each portion
allocated to the file - the file allocation table contains block number
for the index
From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
10Indexed Allocation with Block Portions
File Allocation Table
FileB
File Name
Index Block
0
1
2
3
4
...
...
5
6
7
8
9
FileB
24
...
...
10
11
12
13
14
15
16
17
18
19
1
8
20
21
22
23
24
3
14
25
26
27
28
29
28
30
31
32
33
34
From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
11Indexed Allocation - Var Length Portions
File Allocation Table
FileB
File Name
Index Block
0
1
2
3
4
...
...
5
6
7
8
9
FileC
24
...
...
10
11
12
13
14
15
16
17
18
19
Start Block
Length
20
21
22
23
24
1
3
28
4
14
1
25
26
27
28
29
30
31
32
33
34
From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
12UNIX File Management
- Files are streams of bytes
- Types of files
- ordinary - contents entered by user or program
- directory - contains list of file names and
pointers to inodes (index nodes) - special - used to access peripheral devices
- named - named pipes
- From Operating Systems. Internals and Design
Principles. W. Stallings. Prentice Hall
13UNIX (4K bytes per block)
From Operating System Concepts Silbershatz
Galvin
14Free-Space Management
From Operating System Concepts Silbershatz
Galvin
15Free-Space Management (Cont.)
- Bit map requires extra space. Example
- block size 212 bytes
- disk size 230 bytes (1 gigabyte)
- n 230/212 218 bits (or 32K bytes)
- Easy to get contiguous files
- Linked list (free list)
- Cannot get contiguous space easily
- No waste of space
- Grouping
- Counting
- From Operating System Concepts Silbershatz
Galvin
16Free-Space Management (Cont.)
- Need to protect
- Pointer to free list
- Bit map
- Must be kept on disk
- Copy in memory and disk may differ.
- Cannot allow for blocki to have a situation
where biti 1 in memory and biti 0 on
disk. - Solution
- Set biti 1 in disk.
- Allocate blocki
- Set biti 1 in memory
- From Operating System Concepts Silbershatz
Galvin
17Directory Implementation
- Linear list of file names with pointer to the
data blocks. - simple to program
- time-consuming to execute
- Hash Table linear list with hash data
structure. - decreases directory search time
- collisions situations where two file names hash
to the same location - fixed size
-
From Operating System Concepts Silbershatz
Galvin