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

DFC10103 Topic 3 Part 2 update 5Okt2022

The document discusses file management in operating systems, focusing on various methods of file allocation such as contiguous, linked, and indexed allocation, along with their benefits and weaknesses. It also covers free space management techniques, including bitmaps and linked lists, to efficiently manage disk space. Each allocation method has its own advantages and disadvantages, impacting how files are stored and accessed on a disk.

Uploaded by

dexmon1636
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)
6 views

DFC10103 Topic 3 Part 2 update 5Okt2022

The document discusses file management in operating systems, focusing on various methods of file allocation such as contiguous, linked, and indexed allocation, along with their benefits and weaknesses. It also covers free space management techniques, including bitmaps and linked lists, to efficiently manage disk space. Each allocation method has its own advantages and disadvantages, impacting how files are stored and accessed on a disk.

Uploaded by

dexmon1636
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/ 30

Topic 3: File

Management
Topic 3 Part 2 || Learning Objectives:
CLO 1 (C2, PLO1)
Explain file management in operating
system.
5. Various methods of file allocation:
★ Contiguous file allocation
★ Linked file allocation
★ Indexed file allocation

6. State the benefits and weaknesses of


using each of the file allocation method.
7. Describe the two free space management
techniques:
★ using bit maps/ bit vector
★ using linked lists
Methods of File Allocation:
Contiguous file allocation, Linked file allocation, Indexed file
allocation, and their benefits/weaknesses.
Allocation Method (of Direct Access
Method)
1. Introduction:
★ The direct-access nature of disks allows us
flexibility in the implementation of files, in
almost every case, many files are stored on
the same disk.
2. Problem of direct access:
★ how to allocate space to these files so that
disk space is utilized effectively and files
can be accessed quickly.
… Allocation Method (of Direct Access
Method)
1. An allocation method refers to how disk
blocks are allocated for files.
2. There are three main method of
allocation:
★ Contiguous allocation
★ Linked allocation
★ Indexed allocation
3. Each method has advantages and
disadvantages.
4. Its common for a system to use one
method for all files within a file-system
type.
Contiguous Allocation
1. Contiguous allocation requires that each
file occupy a set of contiguous blocks on
the disk.
2. Disk addresses define a linear ordering on
the disk. With this ordering, assuming that
only one job is accessing the disk,
accessing block b + 1 after block b normally
requires no head movement.
3. When head movement is needed (from the
last sector of one cylinder to the first
sector of the next cylinder), the head need
only move from one track to the next.
★ number of disk seeks required is minimal,
★ meaning seek time is available only when a seek is
finally needed.
… Contiguous Allocation
1. Accessing a file that has been allocated
contiguously is easy.
2. For sequential access, the file system
remembers the disk address of the last
block referenced and, when necessary,
reads the next block.
3. Disdvantages:
★ Where to allocate a new file?
★ How much space needed for a file?

… Contiguous Allocation: Where to allocate
a new file?
1. First fit dan best fit adalah strategi paling biasa
digunakan bagi “Contiguous Allocation”.
2. Kedua-duanya lebih efisyen dari worst fit dalam
hal masa pengurusan storan dan masa.
3. First fit pada asasnya lebih laju berbanding
best fit dalam penggunaan storan.
4. Semasa fail ditempatkan ke dalam memori dan
kemudiannya dibuang. Hal ini menyebabkan
ruang kosong yang berasingan terhasil. Ini
dipanggil “External fragmentation”. Ruang
kosong yang berasingan mungkin tidak dapat
memuatkan fail-fail bersaiz besar.
… Contiguous Allocation: Where to allocate
a new file?
1. Untuk mengatasi masalah “external
fragmentation” ini, keseluruhan sistem fail
perlu disalin/dipindahkan ke peranti lain.
Peranti asal kini kosong sepenuhnya.
Maka sekarang sistem fail yang
dipindahkan tadi boleh dipindah masuk
semula dan ia akan masuk ke dalam
storan secara “contiguous”. Kaedah ini
menyebabkan semua ruang kosong
dimampatkan dan menyelesaikan
masalah “external fragmentation”.
2. Kaedah ini bagaimanapun memerlukan
masa.
… Contiguous Allocation: How much space
needed for a file?
1. Apabila fail diwujudkan ("create"d) , jumlah
ruang yang diperlukan akan diketahui dan
ditempatkan (allocated) kepada fail
tersebut.
2. Bagaimana pencipta fail tahu saiz fail yang
akan diwujudkan? Mereka tidak tahu, tetapi
boleh menganggarkan saiz yang lebih
besar dari sebenar. Tetapi ini menyebabkan
fragmentation.
3. Ruang disediakan perlu bersesuaian
dengan fail tersebut. Kaedah best-fit sesuai
untuk digunakan semasa mencari ruang
bersesuaian.
Contiguous Allocation of Disk Space

Contiguous allocation of disk space.


Linked Allocation
1. Linked Allocation solves contiguous
allocation
2. Simple – need only starting address
3. With linked allocation, each file is a linked
list of disk blocks; the disk blocks may be
scattered anywhere on the disk.
4. The directory contains a pointer to the
first and last blocks of the file. Each block
contains a pointer to the next block.
… Linked Allocation
1. Untuk "create" fail baru, entri baru dicipta
di directory.
2. “Write” ke atas fail menyebabkan
“free-space management system” mencari
blok kosong, dan blok baru ini akan ditulis
(write) dan dihubungkan (linked) ke hujung
fail tersebut.
3. Untuk “read” satu fail, blok dibaca (read)
dengan cara mengikut arah yang ditunjuk
oleh “pointer” dari satu blok ke blok yang
lain.
… Linked Allocation
1. There is no external fragmentation with
linked allocation, and any free block on the
free-space list can be used to satisfy a
request.
2. A file can continue to grow as long as free
blocks are available. So it is never
necessary to compact disk space
… Linked Allocation
1. Contoh penting bagi linked allocation
ialah file-allocation table (FAT) seperti
digunakan oleh MS-DOS Operating
System.
2. Sebahagian ruang dalam storan
disediakan khas untuk FAT, biasanya di
permulaan storan
put some scribble on arrow to show flow of linked list

… Linked Allocation: File-Allocation Table

File-allocation table.
… Linked Allocation: File-Allocation Table
Disdvantages:
1. effectively only for sequential-access files
2. Pointers require space: disk is being used for
pointers, rather than for information
3. Reliability:
★ files are linked together by pointers scattered all
over the disk, and consider what would hap A bug in
the operating-system software or a disk hardware
failure might result in picking up the wrong pointer.
This error could in turn result in linking into the
free-space list or into another file.pen if a pointer
were lost or damaged?
… Linked Allocation

Linked allocation of disk space.


Indexed Allocation
★ Linked allocation solves the
external-fragmentation and
size-declaration problems of
contiguous allocation.
★ However if there is no FAT linked
allocation cannot support efficient
direct access.
★ Indexed allocation solves this problem
… Indexed Allocation
1. This method sole FAT problem brings all
pointers together into the index block.
2. Logical view.

index table
… Indexed Allocation

Indexed allocation of disk space.


… Indexed Allocation
1. Indexed allocation supports direct access
without suffering from external
fragmentation because any free block can
satisfy a request for more space.
2. Disadvantages:
★ wasted space: because pointer
overhead for indexed allocation is
greater than of linked allocation.
★ performance (similar to linked
allocation
Free space management techniques:
bitmaps/ bit vector and linked lists
Free space management techniques
1. Since disk space is limited, we need to reuse the
space from deleted files for new files, if possible.
2. To keep track of free disk space, the system
maintains a free-space list.
3. The free-space list records all free disk
blocks—those not allocated to some file or
directory.
4. To create a file, we search the free-space list for
the required amount of space and allocate that
space to the new file.
5. This space is then removed from the free-space
list.
6. When a file is deleted, its disk space is added to
the free-space list.
… Free space management techniques
1. Frequently, the free-space list is
implemented as a bit map or also
known as bit vector.
2. There are other techniques too, like;
● Linked list
● Grouping
● Counting
● Space Maps
● TRIMing Unused Blocks
Bit Vector
1. Each block is represented by 1 bit.
2. If the block is free, the bit is 1; if the block
is allocated, the bit is 0.
3. For example, consider a disk where blocks
2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 17, 18, 25,26, and 27
are free and the rest of the blocks are
allocated.
4. The free-space bit map would be
001111001111110001100000011100000 ...
… Bit Vector
1. Advantage:
Simple,
Efficient to find the first free blocks or
consecutive free blocks on the disk.
2. Disdvantage:
inefficient unless the entire vector is kept in
main memory (and is written to disk
occasionally for recovery needs).
Linked List
1. This technique link together all the free disk
blocks, keeping a pointer to the first free
block in a special location on the disk and
caching it in memory.
2. This first block contains a pointer to the next
free disk block, and so on.
3. Inefficient: to traverse the list, we must read each
block, which requires substantial I/O time.
4. Fortunately, traversing the free list is not a
frequent action.
5. Advantage: No waste of space
Other type of techniques:
★ Grouping
★ Counting
★ Space maps
★ TRIMing unused blocks
End of

You might also like