SlideShare a Scribd company logo
1
Year & Sem – III year & V Sem
Subject – Operating System
Topic : File Management (UNIT 4)
Presented by – Dr. Nilam Choudhary, Associate Professor, CSE
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
JAIPUR ENGINEERING COLLEGE AND RESEARCH CENTRE
1
1
Believe it or Not
2
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
1
Introduction
3
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
1
Cont..
4
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
1
Cont..
5
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Cont..
6
What is File System?
A file is a collection of correlated information which is recorded on secondary or non-
volatile storage like magnetic disks, optical disks, and tapes. It is a method of data
collection that is used as a medium for giving input and receiving output from that
program.
In general, a file is a sequence of bits, bytes, or records whose meaning is defined by the
file creator and user. Every File has a logical location where they are located for storage
and retrieval.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 7
Objective of File management System
Here are the main objectives of the file management system:
It provides I/O support for a variety of storage device types.
Minimizes the chances of lost or destroyed data
Helps OS to standardized I/O interface routines for user processes.
It provides I/O support for multiple users in a multiuser systems environment.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 8
Properties of a File System
Here, are important properties of a file system:
Files are stored on disk or other storage and do not disappear when a user logs off.
Files have names and are associated with access permission that permits controlled
sharing.
Files could be arranged or more complex structures to reflect the relationship between
them.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 9
File structure
A File Structure needs to be predefined format in such a way that an operating system
understands . It has an exclusively defined structure, which is based on its type.
Three types of files structure in OS:
A text file: It is a series of characters that is organized in lines.
An object file: It is a series of bytes that is organized into blocks.
A source file: It is a series of functions and processes.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 10
File Attributes
A file has a name and data. Moreover, it also stores meta information like file creation date
and time, current size, last modified date, etc. All this information is called the attributes of a
file system.
Here, are some important File attributes used in OS:
Name: It is the only information stored in a human-readable form.
Identifier: Every file is identified by a unique tag number within a file system known as an
identifier.
Location: Points to file location on device.
Type: This attribute is required for systems that support various types of files.
Size. Attribute used to display the current file size.
Protection. This attribute assigns and controls the access rights of reading, writing, and
executing the file.
Time, date and security: It is used for protection, security, and also used for monitoring
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
File Type
11
It refers to the ability of the operating system to differentiate various types of files like
text files, binary, and source files. However, Operating systems like MS_DOS and UNIX
has the following type of files:
Character Special File
It is a hardware file that reads or writes data character by character, like mouse, printer,
and more.
Ordinary files
These types of files stores user information.
It may be text, executable programs, and databases.
It allows the user to perform operations like add, delete, and modify.
Directory Files
Directory contains files and other related information about those files. Its basically a
folder to hold and organize multiple files.
Special Files
These files are also called device files. It represents physical devices like printers, disks,
networks, flash drive, etc.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Functions of File
12
Create file, find space on disk, and make an entry in the directory.
Write to file, requires positioning within the file
Read from file involves positioning within the file
Delete directory entry, regain disk space.
Reposition: move read/write position.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Commonly used terms in File systems
13
Field:
This element stores a single value, which can be static or variable length.
DATABASE:
Collection of related data is called a database. Relationships among elements of data
are explicit.
FILES:
Files is the collection of similar record which is treated as a single entity.
RECORD:
A Record type is a complex data type that allows the programmer to create a new data
type with the desired column structure. Its groups one or more columns to form a new
data type. These columns will have their own names and data type.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
File Access Methods
14
File access is a process that determines the way that files are accessed and read into
memory. Generally, a single access method is always supported by operating systems.
Though there are some operating system which also supports multiple access methods.
Three file access methods are:
Sequential access
Direct random access
Index sequential access
Sequential Access
In this type of file access method, records are accessed in a certain pre-defined
sequence. In the sequential access method, information stored in the file is also
processed one by one. Most compilers access files using this access method.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Cont..
15
Random Access
The random access method is also called direct random access. This method
allow accessing the record directly. Each record has its own address on which
can be directly accessed for reading and writing.
Sequential Access
This type of accessing method is based on simple sequential access. In this
access method, an index is built for every file, with a direct pointer to different
memory blocks. In this method, the Index is searched sequentially, and its pointer
can access the file directly. Multiple levels of indexing can be used to offer
greater efficiency in access. It also reduces the time needed to access a single
record.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Space Allocation
16
In the Operating system, files are always allocated disk spaces.
Three types of space allocation methods are:
Linked Allocation
Indexed Allocation
Contiguous Allocation
Contiguous Allocation
In this method,
Every file users a contiguous address space on memory.
Here, the OS assigns disk address is in linear order.
In the contiguous allocation method, external fragmentation is the biggest issue.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Cont..
17
Linked Allocation
In this method,
Every file includes a list of links.
The directory contains a link or pointer in the first block of a file.
With this method, there is no external fragmentation
This File allocation method is used for sequential access files.
This method is not ideal for a direct access file.
Indexed Allocation
In this method,
Directory comprises the addresses of index blocks of the specific files.
An index block is created, having all the pointers for specific files.
All files should have individual index blocks to store the addresses for disk
space.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 18
File Directories
A single directory may or may not contain multiple
files. It can also have sub-directories inside the
main directory. Information about files is
maintained by Directories. In Windows OS, it is
called folders.
Following is the information which is maintained in a directory:
•Name The name which is displayed to the user.
•Type: Type of the directory.
•Position: Current next-read/write pointers.
•Location: Location on the device where the file header is stored.
•Size : Number of bytes, block, and words in the file.
•Protection: Access control on read/write/execute/delete.
•Usage: Time of creation, access, modification
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 19
Extensions
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 20
Summary
•A file is a collection of correlated information which is recorded on secondary or non-
volatile storage like magnetic disks, optical disks, and tapes.
•It provides I/O support for a variety of storage device types.
•Files are stored on disk or other storage and do not disappear when a user logs off.
•A File Structure needs to be predefined format in such a way that an operating system
understands it.
•File type refers to the ability of the operating system to differentiate different types of files
like text files, binary, and source files.
•Create find space on disk and make an entry in the directory.
•Indexed Sequential Access method is based on simple sequential access
•In Sequential Access method records are accessed in a certain pre-defined sequence
•The random access method is also called direct random access
•Three types of space allocation methods are:
• Linked Allocation
• Indexed Allocation
• Contiguous Allocation
•Information about files is maintained by Directories
1
File Directory
21
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Collection of files is a file directory. The directory contains information about the files,
including attributes, location and ownership. Much of this information, especially that is
concerned with storage, is managed by the operating system. The directory is itself a file,
accessible by various file management routines.
Information contained in a device directory are:
Name
Type
Address
Current length
Maximum length
Date last accessed
Date last updated
Owner id
Protection information
1
Cont..
22
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Operation performed on directory are:
Search for a file
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system
Advantages of maintaining directories are:
Efficiency: A file can be located more quickly.
Naming: It becomes convenient for users as two users can have same name for
different files or may have different name for same file.
Grouping: Logical grouping of files can be done by properties e.g. all java programs,
all games etc.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 23
Structures of Directory in Operating System
A directory is a container that is used to contain folders and file. It organizes files and
folders into a hierarchical manner.
1
Cont..
24
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
SINGLE-LEVEL DIRECTORY
In this a single directory is maintained for all the users.
Naming problem: Users cannot have same name for two files.
Grouping problem: Users cannot group files according to their need.
1
Cont..
25
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Single-level directory –
Single level directory is simplest directory structure.In it all files are contained in same
directory which make it easy to support and understand.A single level directory has a
significant limitation, however, when the number of files increases or when the system
has more than one user. Since all the files are in the same directory, they must have the
unique name . if two users call their dataset test, then the unique name rule violated.
Advantages:
Since it is a single directory, so its implementation is very easy.
If the files are smaller in size, searching will become faster.
The operations like file creation, searching, deletion, updating are very easy in such a
directory structure.
Disadvantages:
There may chance of name collision because two files can not have the same name.
Searching will become time taking if the directory is large.
In this can not group the same type of files together.
1
Cont..
26
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
TWO-LEVEL DIRECTORY
In this separate directories for each user is maintained.
Path name: Due to two levels there is a path name for every file to locate that file.
Now, we can have same file name for different user.
Searching is efficient in this method.
1
Cont..
27
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
As we have seen, a single level directory often leads to confusion of files names among
different users. the solution to this problem is to create a separate directory for each
user.In the two-level directory structure, each user has there own user files directory
(UFD). The UFDs has similar structures, but each lists only the files of a single user.
system’s master file directory (MFD) is searches whenever a new user id=s logged in.
The MFD is indexed by username or account number, and each entry points to the UFD
for that user.
1
Cont..
28
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Advantages:
We can give full path like /User-name/directory-name/.
Different users can have same directory as well as file name.
Searching of files become more easy due to path name and user-grouping.
Disadvantages:
A user is not allowed to share files with other users.
Still it not very scalable, two files of the same type cannot be grouped together in the
same user.
1
Cont..
29
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
TREE-STRUCTURED DIRECTORY :
Directory is maintained in the form of a tree.
Searching is efficient and also there is grouping capability.
We have absolute or relative path name for a file.
1
Cont..
30
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
TREE-STRUCTURED DIRECTORY :
Once we have seen a two-level directory as a tree of height 2, the natural generalization
is to extend the directory structure to a tree of arbitrary height.
This generalization allows the user to create there own subdirectories and to organize
on their files accordingly.
1
Cont..
31
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
TREE-STRUCTURED DIRECTORY :
A tree structure is the most common directory structure. The tree has a root directory,
and every file in the system have a unique path.
Advantages:
Very generalize, since full path name can be given.
Very scalable, the probability of name collision is less.
Searching becomes very easy, we can use both absolute path as well as relative.
Disadvantages:
Every file does not fit into the hierarchical model, files may be saved into multiple
directories.
We can not share files.
It is inefficient, because accessing a file may go under multiple directories.
1
Acyclic graph directory –
32
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
An acyclic graph is a graph with no cycle and allows to share
subdirectories and files. The same file or subdirectories may
be in two different directories. It is a natural generalization of
the tree-structured directory.It is used in the situation like
when two programmers are working on a joint project and
they need to access files.
The associated files are stored in a subdirectory, separating
them from other projects and files of other programmers,
since they are working on a joint project so they want the
subdirectories to be into their own directories. The common
subdirectories should be shared. So here we use Acyclic
directories.
It is the point to note that shared file is not the same as copy
file . If any programmer makes some changes in the
subdirectory it will reflect in both subdirectories.
1
Acyclic graph directory –
33
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Advantages:
We can share files.
Searching is easy due to different-different paths.
Disadvantages:
We share the files via linking, in case of deleting it may
create the problem,
If the link is softlink then after deleting the file we left with a
dangling pointer.
In case of hardlink, to delete a file we have to delete all the
reference associated with it.
1
General graph directory structure –
34
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
In general graph directory structure, cycles
are allowed within a directory structure where
multiple directories can be derived from more
than one parent directory.
The main problem with this kind of directory
structure is to calculate total size or space
that has been taken by the files and
directories.
Advantages:
It allows cycles.
It is more flexible than other directories
structure.
Disadvantages:
It is more costly than others.
It needs garbage collection.
1
FILE ALLOCATION METHODS
35
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
The allocation methods define how the files are stored in the disk blocks. There are
three main disk space or file allocation methods.
Contiguous Allocation
Linked Allocation
Indexed Allocation
The main idea behind these methods is to provide:
Efficient disk space utilization.
Fast access to the file blocks.
All the three methods have their own advantages and disadvantages as discussed
1
FILE ALLOCATION METHODS
36
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Continuous Allocation: A single continuous set
of blocks is allocated to a file at the time of file
creation. Thus, this is a pre-allocation strategy,
using variable size portions. The file allocation
table needs just a single entry for each file,
showing the starting block and the length of the
file.
This method is 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. It is also easy to retrieve a
single block. For example, if a file starts at block
b, and the ith block of the file is wanted, its
location on secondary storage is simply b+i-1.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Cont..
37
The directory entry for a file with contiguous allocation contains
Address of starting block
Length of the allocated portion.
Advantages:
Both the Sequential and Direct Accesses are supported by this.
For direct access, the address of the kth block of the file which starts at block b can easily
be obtained as (b+k).
This is extremely fast since the number of seeks are minimal because of contiguous
allocation of file blocks.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
Cont..
38
Disadvantage
External fragmentation will occur, making it difficult to find contiguous blocks of space of
sufficient length.
Compaction algorithm will be necessary to free up additional space on disk.
Also, with pre-allocation, it is necessary to declare the size of the file at the time of
creation.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 39
Linked Allocation(Non-contiguous allocation) :
Allocation is on an individual block basis. Each
block contains a pointer to the next block in the
chain. Again the file table needs just a single
entry for each file, showing the starting block
and the length of the file. Although pre-
allocation is possible, it is more common simply
to allocate blocks as needed. Any free block can
be added to the chain. The blocks need not be
continuous. Increase in file size is always
possible if free disk block is available. There is
no external fragmentation because only one
block at a time is needed but there can be
internal fragmentation but it exists only in the
last disk block of file.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 40
Linked Allocation(Non-contiguous allocation) :
Advantages:
This is very flexible in terms of file size. File size can be increased easily since the system
does not have to look for a contiguous chunk of memory.
This method does not suffer from external fragmentation. This makes it relatively better in
terms of memory utilization.
Disadvantages:
Because the file blocks are distributed randomly on the disk, a large number of seeks are
needed to access every block individually. This makes linked allocation slower.
It does not support random or direct access. We can not directly access the blocks of a file.
A block k of a file can be accessed by traversing k blocks sequentially (sequential access )
from the starting block of the file via block pointers.
Pointers required in the linked allocation incur some extra overhead.
Internal fragmentation exists in last disk block of file.
There is an overhead of maintaining the pointer in every disk block.
If the pointer of any disk block is lost, the file will be truncated.
It supports only the sequencial access of files.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 41
Indexed Allocation
It addresses many of the problems of contiguous
and chained allocation. In this case, the file
allocation table contains a separate one-level
index for each file.
The index has one entry for each block allocated
to the file. Allocation may be on the basis of
fixed-size blocks or variable-sized blocks.
Allocation by blocks eliminates external
fragmentation, whereas allocation by variable-
size blocks improves locality. This allocation
technique supports both sequential and direct
access to the file and thus is the most popular
form of file allocation.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 42
Indexed Allocation
Advantages:
This supports direct access to the blocks occupied by the file and therefore provides fast
access to the file blocks.
It overcomes the problem of external fragmentation.
Disadvantages:
The pointer overhead for indexed allocation is greater than linked allocation.
For very small files, say files that expand only 2-3 blocks, the indexed allocation would
keep one entire block (index block) for the pointers which is inefficient in terms of memory
utilization. However, in linked allocation we lose the space of only 1 pointer per block.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 43
Cont..
For files that are very large, single index block may not be able to hold all the pointers.
Following mechanisms can be used to resolve this:
Linked scheme: This scheme links two or more index blocks together for holding the
pointers. Every index block would then contain a pointer or the address to the next index
block.
Multilevel index: In this policy, a first level index block is used to point to the second
level index blocks which inturn points to the disk blocks occupied by the file. This can be
extended to 3 or more levels depending on the maximum file size.
Combined Scheme: In this scheme, a special block called the Inode (information
Node) contains all the information about the file such as the name, size, authority, etc
and the remaining space of Inode is used to store the Disk Block addresses which
contain the actual file
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 44
Disk Free Space Management
Just as the space that is allocated to files must be managed ,so the space that is not
currently allocated to any file must be managed. To perform any of the file allocation
techniques,it is necessary to know what blocks on the disk are available. Thus we need a
disk allocation table in addition to a file allocation table.The following are the approaches
used for free space management.
Bit Tables : This method uses a vector containing one bit for each block on the disk. Each
entry for a 0 corresponds to a free block and each 1 corresponds to a block in use.
For example: 00011010111100110001In this vector every bit correspond to a particular
block and 0 implies that, that particular block is free and 1 implies that the block is already
occupied. A bit table has the advantage that it is relatively easy to find one or a contiguous
group of free blocks.
Advantages
a bit table works well with any of the file allocation methods.
Another advantage is that it is as small as possible.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 45
Disk Free Space Management
Free Block List : In this method, each block is assigned a number sequentially and the list
of the numbers of all free blocks is maintained in a reserved block of the disk.
1
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
REFERENCES
46
Text/Reference Books:
1. A. Silberschatz and Peter B Galvin: Operating System Principals, Wiley India
Pvt. Ltd.
2. Achyut S Godbole: Operating Systems, Tata McGraw Hill
3. Tanenbaum: Modern Operating System, Prentice Hall.
4. DM Dhamdhere: Operating Systems – A Concepts Based Approach, Tata
McGraw Hill 5.
5. Charles Crowly: Operating System A Design – Oriented Approach, Tata
McGraw Hill.
Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 47
B.Umamaheswari (Asst. Prof, CSE) , JECRC, JAIPUR

More Related Content

Similar to OS Unit 4.pptx

file management
 file management file management
file management
Sweta Kumari Barnwal
 
Learn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptLearn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems ppt
geethasenthil2706
 
File management
File managementFile management
File management
sangrampatil81
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
Kalai Selvi
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
Ankit Dubey
 
Model of file system
Model of file systemModel of file system
Model of file system
Ishucs
 
File System operating system operating system
File System  operating system operating systemFile System  operating system operating system
File System operating system operating system
Ethiopia Satlliet television
 
File structure
File structureFile structure
File structure
A. S. M. Shafi
 
Operating system 4 files by adi
Operating system 4 files by adiOperating system 4 files by adi
Operating system 4 files by adi
Prof. Dr. K. Adisesha
 
File system in operating system e learning
File system in operating system e learningFile system in operating system e learning
File system in operating system e learning
Lavanya Sharma
 
File management in OS
File management in OSFile management in OS
File management in OS
Bhavik Vashi
 
File concept and access method
File concept and access methodFile concept and access method
File concept and access method
rajshreemuthiah
 
CH11.pdf
CH11.pdfCH11.pdf
CH11.pdf
ImranKhan880955
 
File
FileFile
Chapter12
Chapter12Chapter12
Chapter12
Loyd Morales
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
VrushaliSolanke
 
fileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdf
FraolUmeta
 
File Management
File ManagementFile Management
File Management
ramya marichamy
 
Unit 4 File and Data Management
Unit 4 File and Data ManagementUnit 4 File and Data Management
Unit 4 File and Data Management
Soushilove
 

Similar to OS Unit 4.pptx (20)

file management
 file management file management
file management
 
Learn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptLearn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems ppt
 
File management
File managementFile management
File management
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Model of file system
Model of file systemModel of file system
Model of file system
 
File System operating system operating system
File System  operating system operating systemFile System  operating system operating system
File System operating system operating system
 
File structure
File structureFile structure
File structure
 
Operating system 4 files by adi
Operating system 4 files by adiOperating system 4 files by adi
Operating system 4 files by adi
 
File system in operating system e learning
File system in operating system e learningFile system in operating system e learning
File system in operating system e learning
 
File management in OS
File management in OSFile management in OS
File management in OS
 
File concept and access method
File concept and access methodFile concept and access method
File concept and access method
 
CH11.pdf
CH11.pdfCH11.pdf
CH11.pdf
 
File
FileFile
File
 
Chapter12
Chapter12Chapter12
Chapter12
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
 
fileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdf
 
File Management
File ManagementFile Management
File Management
 
Unit 4 File and Data Management
Unit 4 File and Data ManagementUnit 4 File and Data Management
Unit 4 File and Data Management
 

Recently uploaded

Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 

Recently uploaded (20)

Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 

OS Unit 4.pptx

  • 1. 1 Year & Sem – III year & V Sem Subject – Operating System Topic : File Management (UNIT 4) Presented by – Dr. Nilam Choudhary, Associate Professor, CSE Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR JAIPUR ENGINEERING COLLEGE AND RESEARCH CENTRE 1
  • 2. 1 Believe it or Not 2 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
  • 4. 1 Cont.. 4 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
  • 5. 1 Cont.. 5 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR
  • 6. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Cont.. 6 What is File System? A file is a collection of correlated information which is recorded on secondary or non- volatile storage like magnetic disks, optical disks, and tapes. It is a method of data collection that is used as a medium for giving input and receiving output from that program. In general, a file is a sequence of bits, bytes, or records whose meaning is defined by the file creator and user. Every File has a logical location where they are located for storage and retrieval.
  • 7. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 7 Objective of File management System Here are the main objectives of the file management system: It provides I/O support for a variety of storage device types. Minimizes the chances of lost or destroyed data Helps OS to standardized I/O interface routines for user processes. It provides I/O support for multiple users in a multiuser systems environment.
  • 8. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 8 Properties of a File System Here, are important properties of a file system: Files are stored on disk or other storage and do not disappear when a user logs off. Files have names and are associated with access permission that permits controlled sharing. Files could be arranged or more complex structures to reflect the relationship between them.
  • 9. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 9 File structure A File Structure needs to be predefined format in such a way that an operating system understands . It has an exclusively defined structure, which is based on its type. Three types of files structure in OS: A text file: It is a series of characters that is organized in lines. An object file: It is a series of bytes that is organized into blocks. A source file: It is a series of functions and processes.
  • 10. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 10 File Attributes A file has a name and data. Moreover, it also stores meta information like file creation date and time, current size, last modified date, etc. All this information is called the attributes of a file system. Here, are some important File attributes used in OS: Name: It is the only information stored in a human-readable form. Identifier: Every file is identified by a unique tag number within a file system known as an identifier. Location: Points to file location on device. Type: This attribute is required for systems that support various types of files. Size. Attribute used to display the current file size. Protection. This attribute assigns and controls the access rights of reading, writing, and executing the file. Time, date and security: It is used for protection, security, and also used for monitoring
  • 11. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR File Type 11 It refers to the ability of the operating system to differentiate various types of files like text files, binary, and source files. However, Operating systems like MS_DOS and UNIX has the following type of files: Character Special File It is a hardware file that reads or writes data character by character, like mouse, printer, and more. Ordinary files These types of files stores user information. It may be text, executable programs, and databases. It allows the user to perform operations like add, delete, and modify. Directory Files Directory contains files and other related information about those files. Its basically a folder to hold and organize multiple files. Special Files These files are also called device files. It represents physical devices like printers, disks, networks, flash drive, etc.
  • 12. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Functions of File 12 Create file, find space on disk, and make an entry in the directory. Write to file, requires positioning within the file Read from file involves positioning within the file Delete directory entry, regain disk space. Reposition: move read/write position.
  • 13. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Commonly used terms in File systems 13 Field: This element stores a single value, which can be static or variable length. DATABASE: Collection of related data is called a database. Relationships among elements of data are explicit. FILES: Files is the collection of similar record which is treated as a single entity. RECORD: A Record type is a complex data type that allows the programmer to create a new data type with the desired column structure. Its groups one or more columns to form a new data type. These columns will have their own names and data type.
  • 14. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR File Access Methods 14 File access is a process that determines the way that files are accessed and read into memory. Generally, a single access method is always supported by operating systems. Though there are some operating system which also supports multiple access methods. Three file access methods are: Sequential access Direct random access Index sequential access Sequential Access In this type of file access method, records are accessed in a certain pre-defined sequence. In the sequential access method, information stored in the file is also processed one by one. Most compilers access files using this access method.
  • 15. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Cont.. 15 Random Access The random access method is also called direct random access. This method allow accessing the record directly. Each record has its own address on which can be directly accessed for reading and writing. Sequential Access This type of accessing method is based on simple sequential access. In this access method, an index is built for every file, with a direct pointer to different memory blocks. In this method, the Index is searched sequentially, and its pointer can access the file directly. Multiple levels of indexing can be used to offer greater efficiency in access. It also reduces the time needed to access a single record.
  • 16. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Space Allocation 16 In the Operating system, files are always allocated disk spaces. Three types of space allocation methods are: Linked Allocation Indexed Allocation Contiguous Allocation Contiguous Allocation In this method, Every file users a contiguous address space on memory. Here, the OS assigns disk address is in linear order. In the contiguous allocation method, external fragmentation is the biggest issue.
  • 17. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Cont.. 17 Linked Allocation In this method, Every file includes a list of links. The directory contains a link or pointer in the first block of a file. With this method, there is no external fragmentation This File allocation method is used for sequential access files. This method is not ideal for a direct access file. Indexed Allocation In this method, Directory comprises the addresses of index blocks of the specific files. An index block is created, having all the pointers for specific files. All files should have individual index blocks to store the addresses for disk space.
  • 18. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 18 File Directories A single directory may or may not contain multiple files. It can also have sub-directories inside the main directory. Information about files is maintained by Directories. In Windows OS, it is called folders. Following is the information which is maintained in a directory: •Name The name which is displayed to the user. •Type: Type of the directory. •Position: Current next-read/write pointers. •Location: Location on the device where the file header is stored. •Size : Number of bytes, block, and words in the file. •Protection: Access control on read/write/execute/delete. •Usage: Time of creation, access, modification
  • 19. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 19 Extensions
  • 20. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 20 Summary •A file is a collection of correlated information which is recorded on secondary or non- volatile storage like magnetic disks, optical disks, and tapes. •It provides I/O support for a variety of storage device types. •Files are stored on disk or other storage and do not disappear when a user logs off. •A File Structure needs to be predefined format in such a way that an operating system understands it. •File type refers to the ability of the operating system to differentiate different types of files like text files, binary, and source files. •Create find space on disk and make an entry in the directory. •Indexed Sequential Access method is based on simple sequential access •In Sequential Access method records are accessed in a certain pre-defined sequence •The random access method is also called direct random access •Three types of space allocation methods are: • Linked Allocation • Indexed Allocation • Contiguous Allocation •Information about files is maintained by Directories
  • 21. 1 File Directory 21 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Collection of files is a file directory. The directory contains information about the files, including attributes, location and ownership. Much of this information, especially that is concerned with storage, is managed by the operating system. The directory is itself a file, accessible by various file management routines. Information contained in a device directory are: Name Type Address Current length Maximum length Date last accessed Date last updated Owner id Protection information
  • 22. 1 Cont.. 22 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Operation performed on directory are: Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system Advantages of maintaining directories are: Efficiency: A file can be located more quickly. Naming: It becomes convenient for users as two users can have same name for different files or may have different name for same file. Grouping: Logical grouping of files can be done by properties e.g. all java programs, all games etc.
  • 23. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 23 Structures of Directory in Operating System A directory is a container that is used to contain folders and file. It organizes files and folders into a hierarchical manner.
  • 24. 1 Cont.. 24 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR SINGLE-LEVEL DIRECTORY In this a single directory is maintained for all the users. Naming problem: Users cannot have same name for two files. Grouping problem: Users cannot group files according to their need.
  • 25. 1 Cont.. 25 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Single-level directory – Single level directory is simplest directory structure.In it all files are contained in same directory which make it easy to support and understand.A single level directory has a significant limitation, however, when the number of files increases or when the system has more than one user. Since all the files are in the same directory, they must have the unique name . if two users call their dataset test, then the unique name rule violated. Advantages: Since it is a single directory, so its implementation is very easy. If the files are smaller in size, searching will become faster. The operations like file creation, searching, deletion, updating are very easy in such a directory structure. Disadvantages: There may chance of name collision because two files can not have the same name. Searching will become time taking if the directory is large. In this can not group the same type of files together.
  • 26. 1 Cont.. 26 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR TWO-LEVEL DIRECTORY In this separate directories for each user is maintained. Path name: Due to two levels there is a path name for every file to locate that file. Now, we can have same file name for different user. Searching is efficient in this method.
  • 27. 1 Cont.. 27 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR As we have seen, a single level directory often leads to confusion of files names among different users. the solution to this problem is to create a separate directory for each user.In the two-level directory structure, each user has there own user files directory (UFD). The UFDs has similar structures, but each lists only the files of a single user. system’s master file directory (MFD) is searches whenever a new user id=s logged in. The MFD is indexed by username or account number, and each entry points to the UFD for that user.
  • 28. 1 Cont.. 28 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Advantages: We can give full path like /User-name/directory-name/. Different users can have same directory as well as file name. Searching of files become more easy due to path name and user-grouping. Disadvantages: A user is not allowed to share files with other users. Still it not very scalable, two files of the same type cannot be grouped together in the same user.
  • 29. 1 Cont.. 29 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR TREE-STRUCTURED DIRECTORY : Directory is maintained in the form of a tree. Searching is efficient and also there is grouping capability. We have absolute or relative path name for a file.
  • 30. 1 Cont.. 30 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR TREE-STRUCTURED DIRECTORY : Once we have seen a two-level directory as a tree of height 2, the natural generalization is to extend the directory structure to a tree of arbitrary height. This generalization allows the user to create there own subdirectories and to organize on their files accordingly.
  • 31. 1 Cont.. 31 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR TREE-STRUCTURED DIRECTORY : A tree structure is the most common directory structure. The tree has a root directory, and every file in the system have a unique path. Advantages: Very generalize, since full path name can be given. Very scalable, the probability of name collision is less. Searching becomes very easy, we can use both absolute path as well as relative. Disadvantages: Every file does not fit into the hierarchical model, files may be saved into multiple directories. We can not share files. It is inefficient, because accessing a file may go under multiple directories.
  • 32. 1 Acyclic graph directory – 32 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR An acyclic graph is a graph with no cycle and allows to share subdirectories and files. The same file or subdirectories may be in two different directories. It is a natural generalization of the tree-structured directory.It is used in the situation like when two programmers are working on a joint project and they need to access files. The associated files are stored in a subdirectory, separating them from other projects and files of other programmers, since they are working on a joint project so they want the subdirectories to be into their own directories. The common subdirectories should be shared. So here we use Acyclic directories. It is the point to note that shared file is not the same as copy file . If any programmer makes some changes in the subdirectory it will reflect in both subdirectories.
  • 33. 1 Acyclic graph directory – 33 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Advantages: We can share files. Searching is easy due to different-different paths. Disadvantages: We share the files via linking, in case of deleting it may create the problem, If the link is softlink then after deleting the file we left with a dangling pointer. In case of hardlink, to delete a file we have to delete all the reference associated with it.
  • 34. 1 General graph directory structure – 34 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR In general graph directory structure, cycles are allowed within a directory structure where multiple directories can be derived from more than one parent directory. The main problem with this kind of directory structure is to calculate total size or space that has been taken by the files and directories. Advantages: It allows cycles. It is more flexible than other directories structure. Disadvantages: It is more costly than others. It needs garbage collection.
  • 35. 1 FILE ALLOCATION METHODS 35 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR The allocation methods define how the files are stored in the disk blocks. There are three main disk space or file allocation methods. Contiguous Allocation Linked Allocation Indexed Allocation The main idea behind these methods is to provide: Efficient disk space utilization. Fast access to the file blocks. All the three methods have their own advantages and disadvantages as discussed
  • 36. 1 FILE ALLOCATION METHODS 36 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Continuous Allocation: A single continuous set of blocks is allocated to a file at the time of file creation. Thus, this is a pre-allocation strategy, using variable size portions. The file allocation table needs just a single entry for each file, showing the starting block and the length of the file. This method is 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. It is also easy to retrieve a single block. For example, if a file starts at block b, and the ith block of the file is wanted, its location on secondary storage is simply b+i-1.
  • 37. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Cont.. 37 The directory entry for a file with contiguous allocation contains Address of starting block Length of the allocated portion. Advantages: Both the Sequential and Direct Accesses are supported by this. For direct access, the address of the kth block of the file which starts at block b can easily be obtained as (b+k). This is extremely fast since the number of seeks are minimal because of contiguous allocation of file blocks.
  • 38. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR Cont.. 38 Disadvantage External fragmentation will occur, making it difficult to find contiguous blocks of space of sufficient length. Compaction algorithm will be necessary to free up additional space on disk. Also, with pre-allocation, it is necessary to declare the size of the file at the time of creation.
  • 39. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 39 Linked Allocation(Non-contiguous allocation) : Allocation is on an individual block basis. Each block contains a pointer to the next block in the chain. Again the file table needs just a single entry for each file, showing the starting block and the length of the file. Although pre- allocation is possible, it is more common simply to allocate blocks as needed. Any free block can be added to the chain. The blocks need not be continuous. Increase in file size is always possible if free disk block is available. There is no external fragmentation because only one block at a time is needed but there can be internal fragmentation but it exists only in the last disk block of file.
  • 40. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 40 Linked Allocation(Non-contiguous allocation) : Advantages: This is very flexible in terms of file size. File size can be increased easily since the system does not have to look for a contiguous chunk of memory. This method does not suffer from external fragmentation. This makes it relatively better in terms of memory utilization. Disadvantages: Because the file blocks are distributed randomly on the disk, a large number of seeks are needed to access every block individually. This makes linked allocation slower. It does not support random or direct access. We can not directly access the blocks of a file. A block k of a file can be accessed by traversing k blocks sequentially (sequential access ) from the starting block of the file via block pointers. Pointers required in the linked allocation incur some extra overhead. Internal fragmentation exists in last disk block of file. There is an overhead of maintaining the pointer in every disk block. If the pointer of any disk block is lost, the file will be truncated. It supports only the sequencial access of files.
  • 41. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 41 Indexed Allocation It addresses many of the problems of contiguous and chained allocation. In this case, the file allocation table contains a separate one-level index for each file. The index has one entry for each block allocated to the file. Allocation may be on the basis of fixed-size blocks or variable-sized blocks. Allocation by blocks eliminates external fragmentation, whereas allocation by variable- size blocks improves locality. This allocation technique supports both sequential and direct access to the file and thus is the most popular form of file allocation.
  • 42. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 42 Indexed Allocation Advantages: This supports direct access to the blocks occupied by the file and therefore provides fast access to the file blocks. It overcomes the problem of external fragmentation. Disadvantages: The pointer overhead for indexed allocation is greater than linked allocation. For very small files, say files that expand only 2-3 blocks, the indexed allocation would keep one entire block (index block) for the pointers which is inefficient in terms of memory utilization. However, in linked allocation we lose the space of only 1 pointer per block.
  • 43. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 43 Cont.. For files that are very large, single index block may not be able to hold all the pointers. Following mechanisms can be used to resolve this: Linked scheme: This scheme links two or more index blocks together for holding the pointers. Every index block would then contain a pointer or the address to the next index block. Multilevel index: In this policy, a first level index block is used to point to the second level index blocks which inturn points to the disk blocks occupied by the file. This can be extended to 3 or more levels depending on the maximum file size. Combined Scheme: In this scheme, a special block called the Inode (information Node) contains all the information about the file such as the name, size, authority, etc and the remaining space of Inode is used to store the Disk Block addresses which contain the actual file
  • 44. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 44 Disk Free Space Management Just as the space that is allocated to files must be managed ,so the space that is not currently allocated to any file must be managed. To perform any of the file allocation techniques,it is necessary to know what blocks on the disk are available. Thus we need a disk allocation table in addition to a file allocation table.The following are the approaches used for free space management. Bit Tables : This method uses a vector containing one bit for each block on the disk. Each entry for a 0 corresponds to a free block and each 1 corresponds to a block in use. For example: 00011010111100110001In this vector every bit correspond to a particular block and 0 implies that, that particular block is free and 1 implies that the block is already occupied. A bit table has the advantage that it is relatively easy to find one or a contiguous group of free blocks. Advantages a bit table works well with any of the file allocation methods. Another advantage is that it is as small as possible.
  • 45. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 45 Disk Free Space Management Free Block List : In this method, each block is assigned a number sequentially and the list of the numbers of all free blocks is maintained in a reserved block of the disk.
  • 46. 1 Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR REFERENCES 46 Text/Reference Books: 1. A. Silberschatz and Peter B Galvin: Operating System Principals, Wiley India Pvt. Ltd. 2. Achyut S Godbole: Operating Systems, Tata McGraw Hill 3. Tanenbaum: Modern Operating System, Prentice Hall. 4. DM Dhamdhere: Operating Systems – A Concepts Based Approach, Tata McGraw Hill 5. 5. Charles Crowly: Operating System A Design – Oriented Approach, Tata McGraw Hill.
  • 47. Dr. Nilam Choudhary ,CSE, JECRC, JAIPUR 47 B.Umamaheswari (Asst. Prof, CSE) , JECRC, JAIPUR