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

DOC-20241022-WA0010.

The document discusses various file access methods, including sequential, direct, and indexed sequential access, each with its own characteristics and use cases. It also outlines key characteristics of files, functions of file systems, types of file systems, directory structures, and file allocation methods. Understanding these concepts is essential for effective file management and organization in operating systems.

Uploaded by

oanjali854
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)
8 views

DOC-20241022-WA0010.

The document discusses various file access methods, including sequential, direct, and indexed sequential access, each with its own characteristics and use cases. It also outlines key characteristics of files, functions of file systems, types of file systems, directory structures, and file allocation methods. Understanding these concepts is essential for effective file management and organization in operating systems.

Uploaded by

oanjali854
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/ 26

file access methods

method by which information stored in files can be


accessed and read from memory is called access
methods.

File access methods are as follows:-

1:- sequential access

2:- direct access

3:- indexed sequential access

1:- Sequential access:- This method access is common. In


sequential access, the information present in the file is
accessed in sequence. That is, information is accessed
one after the other in sequence.
Like:- We have a file which contains 5 records r1, r2, r3,
r4,r5.
So we will first access r1, then r2 and then finally r5. We
cannot access r5 directly.

This method is mostly used by editors and compilers.

2:- Direct access:- Direct access is also called random


access.

Through direct access, we can directly access any


information present in the file. Through this we can access
the file at a very fast speed.

Every information in the file has its own address, so with


the help of that address it is directly accessed for read and
write.

Sometimes we do not need to access every information of


the file and we do not need to access the information in
sequence, so in all cases we use direct access.

This method is generally used in databases.

3:- Indexed sequential access:- This method is built on the


basis of sequential access. In this, an index is created for
each file which contains pointers to different blocks.

In this, the index is used to control the pointer while


accessing the file.

Characteristics of files system

Files have several key characteristics that define their


properties and how they can be used. Here are the main
characteristics:

1. Name: Each file has a unique name within its directory,


which often includes a file extension (e.g., .txt, .jpg) that
indicates its format.
2. Type: Files can be categorized by type, such as text
files, image files, audio files, video files, executable files,
etc. The type often determines how the file can be opened
and edited.

3. Size: The file size is measured in bytes and indicates


how much data the file contains. Larger files typically take
up more storage space and may take longer to transfer.

4. Location: Files are stored in specific locations within a


file system, usually organized in directories or folders.

5. Timestamp: Files have associated timestamps that


indicate when they were created, last modified, and last
accessed. These timestamps can be useful for tracking
changes and backups.

6. Permissions: Files have permissions that dictate who


can read, write, or execute the file. These permissions
help protect sensitive data and control access.

7. Metadata: Files often contain metadata, which is data


about the file itself, such as author, title, and keywords.
This information can help in organizing and searching for
files.

8. Content: The actual data stored within the file, which


can vary widely depending on the file type (text, images,
code, etc.).
Understanding these characteristics is essential for
effective file management and organization in any
operating system.

Q.6 What are the functions of file system?

Ans. Here's an even more detailed explanation of the


functions of a File System in an Operating System:

*Primary Functions*

1. *File Creation*: The file system provides a mechanism


for creating new files and directories. This includes
allocating space on the disk, assigning a file name, and
setting permissions.

2. *File Deletion*: The file system allows files and


directories to be deleted, freeing up disk space.

3. *File Retrieval*: The file system provides access to files,


allowing users to read file contents.

4. *File Update*: The file system enables modification of


file contents.

5. *File Naming*: The file system manages file names and


extensions.
*File Management Functions*

1. *File Organization*: The file system organizes files into


directories and subdirectories, making it easier to locate
and manage files.

2. *File Protection*: The file system implements access


control and permissions to ensure files are secure.

3. *File Sharing*: The file system allows multiple users to


access shared files.

4. *File Backup*: The file system provides mechanisms for


creating backups of critical files.

5. *File Recovery*: The file system provides tools for


recovering deleted or corrupted files.

*Storage Management Functions*

1. *Disk Space Allocation*: The file system manages disk


space allocation for files.

2. *File Allocation Table (FAT)*: The file system manages


file location and size.

3. *Block Allocation*: The file system allocates disk blocks


for file storage.
4. *Disk Quotas*: The file system enforces disk usage
limits for users.

*Security Functions*

1. *Access Control*: The file system implements file-level


access control.

2. *Encryption*: The file system encrypts files for secure


storage.

3. *File Permissions*: The file system sets permissions for


file access.

4. *Authentication*: The file system verifies user identity


for file access.

*Performance Optimization Functions*

1. *Caching*: The file system improves file access


performance using caching.

2. *Buffering*: The file system optimizes file transfer using


buffering.

3. *Defragmentation*: The file system reorganizes files for


efficient storage.

4. *Disk Scheduling*: The file system optimizes disk


access for better performance.

*Additional Functions*

1. File Compression: The file system compresses files for


efficient storage.

2. File Fragmentation: The file system manages file


fragmentation.

3. File Journaling: The file system records file system


changes.

4. File System Check: The file system verifies file system


integrity.

Q.7 how many types of file system are there?

Ans. There are many types of file systems and each of


them is completely different from each other. Each file
system has its own logical structure and properties, such
as its speed and size.

These file systems may vary depending on the operating


system. This is because each operating system and its
way of working is completely different from each other.

Therefore, the type of file system may vary depending on


the operating system and the requirements of that
operating system. Currently the most commonly used OS
are Microsoft Windows, Mac operating system and Linux
operating system.

Similarly, two different types of operating systems are


currently used in smartphones. Like Apple iOS for Apple
users and Android OS for others.

Below we are going to tell you about some big file systems
which are used today by users and organizations all over
the world

file Allocation Table (FAT)


FAT file system is supported by Microsoft Windows OS,
FAT file system is simple and reliable. Also, this FAT file
system is modeled after legacy file systems.

This file system was specifically designed for floppy disks


in 1977. But later it was adapted for hard disks, the current
FAT file system is efficient and compatible with all types of
operating systems.

But as we told you that this FAT file system was created in
1977. Therefore, this file system cannot compete with the
performance and scalability of most of the currently
existing modern file systems.

Global File System (GFS)


Global File System, also known as GFS in short form, is a
file system for Linux OS. Besides this, it is a shared disk
file system, it can also be used as a local file system.

Apart from this, GFS allows direct access to shared block


storage. Currently its updated version has arrived which is
called GFS2. In gFS2 you get such features which you
could not see in the earlier original GFS.

Like in this you get to see the updated metadata system


which is not seen in its old and original version.

According to the terms of the gNU General Public License,


both the GFS and GFS2 file systems are available as free
software. Which you can use in your computer and those
devices in which Linux operating system is installed.

Hierarchical File System (HFS)


hFS i.e. hierarchical file system was developed specifically
for use with Mac operating systems. HFS refers
specifically to Mac OS Standard, later replaced by Mac
OS Extended.

hFS was first developed in 1985 for floppy disks and hard
disks. After the arrival of HFS, it completely replaced the
original Macintosh file system.

This happened because the HFS file system could be


used for CDs and ROMs in addition to floppy disks and
hard disks.
You can use NTFS for your Linux OS through open source
NTFS driver. On the other hand, for Mac OS it is available
only with read-only support.

Universal Disk Format (UDF)


This file system is a file system used on optical media and
DVD. Currently UDF has replaced the ISO 9660 file
system. Additionally, it has now become an official file
system for DVD video and audio after being selected by
the DVD Forum

Q.8 Explain the tree structure of file management

Ans. What is Directory Structure?


In an operating system, a directory is a container that is
used to store folders and files. It organizes files and
folders in a hierarchical manner.

In other words, “a directory is a collection of files on a


disk.”

Many users create thousands and millions of files in a file


system. Directory structure is used by the file system to
organize these files well.

In simple words, “Directory structure is a structure that is


used by the file system to organize files and folders in a
better way.
types of Directory structure in Hindi – Types of Directory
structure
Following are the types of directory structure:-

1:- Single level directory structure


Single level directory structure has only one directory
which is called root directory. In this, users are not allowed
to create sub-directories inside the root directory. Files
created by different users are stored only in the root
directory

Its advantages –
1. This is the simplest directory structure and is very easy
to implement.

2. If the size of the files is small then they can be searched


very fast.

3. In this directory structure it is easy to create, update,


delete and search a file

Its disadvantages –

1. In this, two files cannot have the same name. If a user


has named his file similar to an already existing file. So the
old file will be deleted. the directory is very large then it
takes a lot of time to search the file.
In this we cannot keep similar types of files in one group.
2:- Two-level directory structure
In this directory structure, a user can create a directory
directly inside the root directory but the user cannot create
sub-directories inside that created directory.

3. Through two-level file directory structure, each user can


create his own directory and store files.

2:- Two-level directory structure


In this directory structure, a user can create a directory
directly inside the root directory but the user cannot create
sub-directories inside that created directory.
Through two-level file directory structure, each user can
create his own directory and store files.

Its advantages –

1. In this we can give the complete path like:-


/user-name/directory-name.

2. We can give the same name of the file in it but in a


different directory.

3. Due to pathname and user-grouping, it becomes easy


to search the file in it.

Its disadvantages –

1. In this the user cannot share the file with other users.

2. It is not very scalable because files of the same type


cannot be kept in one group.
3:- Tree Directory Structure
In this, except the root directory, every directory or file has
only one parent directory. This removes the shortcomings
of the two-level directory. In this we can keep similar types
of files in one group.

A tree structure is the most commonly used directory


structure. Tree has a root directory and every file in the
system has a unique path

advantage –

1. In this we can give the complete pathname.


It is very scalable because we can keep similar types of
files in one group.

2. There is very little name collision in this.


Searching in this is very easy because apart from absolute
path, we can also use relative path.
Its disadvantages –

1. In this we cannot share files.

2. It is not efficient because to access a file we have to go


to many directories.

3. In this, every file does not fit in the hierarchical model,


hence we have to save the files in many directories.

4:- Acyclic-Graph Directory Structure


An acyclic-graph is a graph that does not contain cycles
and in which sub-directories and files can be shared. In
this directory structure, a file or directory has many parent
directories.

It is used in a situation when two programmers are


working on the same project and they need files. So
programmers can save and share their files in different
directories.
Its benefits –

1. Through this we can share files.


2. Due to different paths, it is easy to search files in it.

Its disadvantages –

1. We share files through linking, so we may face


2.problems while deleting them.

3. If the link is a softlink, then after deleting the file, only a


dangling pointer is left.

4. If the link is a hardlink, then when we delete the file, we


will also have to delete the references related to it.

5:- General graph directory structure


In this directory structure, we can create a cycle of
directories within the directory where we can derive
multiple directories.

The main problem with this type of directory structure is


that it is very difficult to calculate the memory size or
space taken by files and directories

Its benefits –

1. Cycles can be created in this.


2. It is more flexible than other directory structures.

Its disadvantages –

1. It is more expensive than others.


2. It needs garbage collection

Q.9 write, what are the show allocation methods of file


management?
Ans. file allocation methods
Storing files in disk blocks is called allocation.
File Allocation methods define how any file is stored in the
disk block. In the operating system, three allocation
methods are used to store files in disk blocks which are as
follows:-

1. Contiguous Allocation
2. Linked Allocation
3. Indexed Allocation

These three methods are used to effectively utilize disk


blocks and access files faster. But all three have some
advantages and some disadvantages. Which we will read
below.

Contiguous allocation
In the contiguous allocation method, the user has to
specify the file size before creating the file. After that, the
operating system finds contiguous blocks in the disk
based on the size of that file and allocates the file.

If no contiguous block of the file's size is available then the


file cannot be created.

You can see in the picture below that there are 5 files in
the directory and the length and starting disk block of each
file is shown in the table
advantage of contiguous allocation
Its benefits are as follows:-

1. It is very easy to implement because blocks of files can


be easily tracked.
2. It supports both direct access and sequential access.
3. Any file can be read easily in this.
4. It supports random access to files.
5. This is a very fast method.

Disadvantages:-
Its disadvantages are as follows:-

1. In this the disk becomes fragmented. In this both


external and internal fragmentation occurs.

2. There is difficulty in increasing the size of the file


because it depends on contiguous memory.

linked linked allocation in hindi


In this allocation, each file is a linked list of disk blocks.
And in this the file is not allocated in contiguous blocks.
Disk blocks can be anywhere in the disk.

In this, the directory of the file contains the pointer to the


first block and the last block. This method is also called
chained allocation. And in this the file is not allocated in
contiguous blocks. Disk blocks can be anywhere in the
disk.

In this, the directory of the file contains the pointer to the


first block and the last block. This method is also called
chained allocation

advantage of linked allocation

1. There is no external fragmentation in this method.


2. In this we do not need to specify the size of the file.

3. If there is any free block then it can be easily utilized.


4. The size of the file can be increased as long as free
blocks are available.
5. There is no need to perform compaction in this
6. It supports sequential access.

Disadvantages:-
Its disadvantages are as follows:-

1. Random access is not available in this.


2. Pointers require some space in disk blocks.
3. There should not be any broken pointer in the linked list
because in this case the entire file will get corrupted.
4. Each block needs to be traversed, which makes this
method slow.
5. It does not support direct access.

Indexed allocation
This removes the problems faced in contiguous and linked
allocation.

In this method, there is a special type of block which is


called index block. This index block contains all the
pointers of the file. Each file has its own index block.

The directory entry also holds the address of the index


block as you can see in the picture below.

advantage of indexed allocation

1. This is the most commonly used file allocation methods.


It supports direct access and sequential access.

2. There is no external fragmentation in this.

3. In this, if any data block gets damaged then only that


block will be damaged.

Disadvantages:-

1. If there is any problem in one index block then the entire


file gets lost.
2. The size of the file depends on the index block.
Having an index block for a small file is a wastage of
memory.
3. In this method the overhead of pointers is more

Q.10 write a note on the following


1. Virtual memory: Virtual memory makes our system
appear larger than the physical memory of the system.
That is, virtual memory makes the physical memory of the
system much larger.

“Storing a program's data and instructions in secondary


memory and loading them into main memory when they
are needed.” This is the basic concept of virtual memory.

In other words, “that part of a program which is needed


whenever it is needed is loaded into the main memory and
the remaining part remains in the secondary memory only.

Virtual memory is used to separate the logical address


space available to the user and the actual physical
memory.

C.P.U. The address generated by is called logical address


or virtual address. Programmers use virtual addresses in
applications. What is mMU(memory management unit) is
that it converts the virtual address into physical memory
address.
The big advantage of virtual memory is that programmers
can also write large programs because virtual memory is
very large compared to physical memory

fig:- It is shown in the figure that virtual memory is larger


than physical memory.

demand paging : Demand paging is a technique in which


pages are not brought from secondary memory (hard disk)
to main memory (RAM) until they are needed.

Demand paging is a combination of paging and swapping.

Demand paging is similar to normal paging but the main


difference is that swapping is used in demand paging.
That is, all the pages remain in the hard disk and when
they are needed, they are swapped in and swapped out in
the RAM.

When we execute any process in the operating system,


that process is first stored in the hard disk. This process
takes place in the form of pages.

Whenever a page is needed, it is swapped in RAM. For


this reason it is also called lazy swapping. And when a
page is not needed in RAM, it is swapped out and sent
back to the hard disk.

,To swap pages from hard disk or RAM, we have to use


page table. Page table is used to store page number and
offset number. The offset number contains the address of
the process.

There are also two entries in the page table – valid and
invalid. In this, if the page required is in the hard disk, then
it will give a valid entry for it. And if it is not there then it will
give invalid entry

You might also like