0% found this document useful (0 votes)
25 views26 pages

Lecture 40,41

Uploaded by

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

Lecture 40,41

Uploaded by

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

Operating Systems

Concepts
LECTURE 40,41 – FILE MANAGEMENT: RECORD BLOCKING, FILE
ALLOCATION METHODS, FREE SPACE MANAGEMENT
Record Blocking

 Records are the logical unit of access of a structured file


 But blocks are the unit for I/O with secondary storage
 The process of organizing records in blocks is called Record Blocking
 Three approaches are common
 Fixed length blocking
 Variable length spanned blocking
 Variable-length unspanned blocking
Fixed Blocking

 Fixed-length records are used, and an integral number of records are


stored in a block.
 Unused space at the end of a block is internal fragmentation
Fixed Blocking
Variable Length Spanned Blocking

 Variable-length records are used and are packed into blocks with no
unused space.
 Some records may span multiple blocks
 Continuation is indicated by a pointer to the successor block
Variable Blocking: Spanned
Variable-length unspanned blocking

 Uses variable length records without spanning


 Wasted space in most blocks because of the inability to use the
remainder of a block if the next record is larger than the remaining
unused space.
Variable Blocking: Unspanned
Secondary Storage Management

 The Operating System is responsible for allocating blocks to files


 Two related issues
 Space must be allocated to files
 Must keep track of the space available for allocation
File allocation issues

1. When a file is created – is the maximum space allocated at once?


2. Space is added to a file in contiguous ‘portions’
 What size should be the ‘portion’?
3. What data structure should be used to keep track of the file portions?
Preallocation vs Dynamic Allocation

 A pre-allocation policy requires that the maximum size of a file be


declared at the time of the file creation request.
 Sometimes such as program compilations, the production of summary
data files, or the transfer of a file from another system over a
communications network, this value can be reliably estimated.
 But usually it is difficult if not impossible to estimate reliably the maximum
potential size of the file.
 In those cases, users and application programmers would tend to
overestimate file size, leading to wasted space
 Thus, there are advantages to the use of dynamic allocation, which
allocates space to a file in portions as needed.
Portion size

 Portion: Contiguous set of Allocated Blocks


 Two extremes:
 Portion large enough to hold entire file is allocated
 Allocate space one block at a time
 Trade-off between efficiency from the point of view of a single file, or
the overall system efficiency
File Allocation Method

 Three methods are in common use:


 contiguous,
 chained, and
 indexed.
Contiguous Allocation

 Single set of blocks is allocated to a file at the time of creation


 This is a pre-allocation strategy, using variable-size portions.
 Only a single entry in the file allocation table
 Starting block and length of the file
 External fragmentation will occur
 Need to perform compaction
 Contiguous allocation is the best from the point of view of the individual
sequential file.
 Multiple blocks can be read in at a time to improve I/O performance for sequential
processing.
 Individual blocks can also be easily found
Contiguous 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 external fragmentation
 Best for sequential files
 To select an individual block of a file requires tracing through the chain to the desired
block.
 Although pre-allocation is possible, it is more common simply to allocate blocks
as needed.
 The selection of blocks is now a simple matter: any free block can be added to a
chain.
Chained 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
 Typically, the file indexes are not physically stored as part of the file allocation
table.
 Rather, the file index for a file is kept in a separate block, and the entry for the file in
the file allocation table points to that block.
 The file allocation table contains block number for the index
 Allocation may be either
 Fixed size blocks or
 Variable sized blocks
 Allocating by blocks eliminates external fragmentation
Indexed allocation with Block
Portions
Indexed Allocation with Variable
Length Portions
Free Space Management

 Just as allocated space must be managed, so must the unallocated


space
 To perform file allocation, we need to know which blocks are available.
 We need a disk allocation table in addition to a file allocation table
Bit Tables

 This method uses a vector containing one bit for each block on the disk.
 Each entry of a 0 corresponds to a free block,
 and each 1 corresponds to a block in use.
 Advantages:
 Works well with any file allocation method
 Small as possible
Chained Free Portions

 The free portions may be chained together by using a pointer and


length value in each free portion.
 Negligible space overhead
 Suited to all file allocation methods
Indexing

 Treats free space as a file and uses an index table as it would for file
allocation
 For efficiency, the index should be on the basis of variable-size portions
rather than blocks.
 Thus, there is one entry in the table for every free portion on the disk.
 This approach provides efficient support for all of the file allocation
methods.
Free Block List

 Each block is assigned a number sequentially


 the list of the numbers of all free blocks is maintained in a reserved portion
of the disk.
Thank You!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy