0% found this document useful (0 votes)
39 views7 pages

6.file Managment

Uploaded by

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

6.file Managment

Uploaded by

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

6.

File Management

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.

Describe any four file attributes //2M


File Attributes
File is identified by its name which is string of the characters. Every file has a name and its data. All
operating systems associate other information with each file, for example, the date and time of file
creation and the size of the file. Such extra information associated by operating system is called as
attributes.
The lists of attributes are not same for all the systems and vary from one operating system to another.

 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.

List any four file operations. 4marks


File Operations :
Files store information and allow it to access it later. Different systems provide different operations to
allow storage and retrieval. The operating system can provide system calls to create, write, read,
reposition. Following are the most common system calls relating to files.

1.Create
Creation of the file is the most important operation on the file. Different types of files are created
by different methods for example text editors are used to create a text file, word processors are
used to create a word file and Image editors are used to create the image files.
2.Delete
Deleting the file will not only delete all the data stored inside the file, It also deletes all the
attributes of the file. The space which is allocated to the file will now become available and can
be allocated to the other files.
3. Open:
Process must open the file before using it. Attributes and list of disk addresses are obtained into
main memory for fast access next time.
4. Close :
When use of the file completes, all accesses gets finished. The attributes and disk addresses are
no longer required, so the file should be closed to free up internal table space.
5.Read
Every file is opened in three different modes : Read, Write and append. A Read pointer is
maintained by the OS, pointing to the position up to which, the data has been read.
6.Write
Writing the file is different from creating the file. The OS maintains a write pointer for every file
which points to the position in the file from which, the data needs to be written.

7.Re-position
Re-positioning is simply moving the file pointers forward or backward depending upon the user's
requirement. It is also called as seeking.

8.Rename :
User needs to change the name of an existing file. This system call makes that possible.

File Types//skip
Several operating systems support many types of files. Following are the different types of files.
1. Regular files : Regular files contain user information. The byte sequence, record sequence and
tree structured explained above are the examples of regular files.
2.Directories : These are system files for mzaintaining the structure of the file system.
3.Character special files : These are related to input/output and used to model serial i/o devices
such as terminals, printers, and networks.
4. Block special files : These are used to model disks.

File System Structure:


1. Unstructured sequence of bytes
In this structuring, operating system treats content of the file a sequence of bytes. Any meaning
must be imposed by user-level programs.
Both UNIX and Windows use this approach. This structuring provides more flexibility. Any
types of content can be kept in the file and as per convenience of the user, name can be given to
the file.

2. Sequence of fixed-length records punch card -


Fixed-length records means setting a length and storing the records into the file. If the record size
exceeds the fixed size, it gets divided into more than one block.
In this approach file is treated as sequence of fixed length records. Each record has its internal
structure. Any read operation on file returns one record and write operation will append or
overwrite one record.
When punched cards were in use, record size was of 80 characters and of 132 characters proposed
for line printers. Many operating systems based their file systems on files consisting of 80
character records when punched cards were in use.
Programs read input from file in the unit of 80 characters and wrote in units of 132 characters
keeping remaining 52 characters blank.

3. Tree structure
In this organization, a file consists of the records which are organized in tree structure. All the
records not necessarily have same length. Each record has a key field in a fixed position.
The records in the tree are arranged in the sorted order of key field, to permit quick searching for
a particular key. The main aim in this type of organization is to search record on particular key.
The next record also can be searched.
Operating system decides where to add new record. User is not concern about this operation. This
type of the is broadly used on the large mainframe computers and still used in some commercial
data processing
Following Figs. 6.1.2 (a),(b) and (c) shows three kinds of files. Fig. 6.1.2 (c) shows the tree of
records of student file arranged in sorted order of roll numbers.
Describe sequential and direct access method. //4M 2022
File Access Methods
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.
Two file access methods are:
 Sequential access
 Direct random 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.While
accessing,skipping of any record or reading them out of order is not possible.
This access method was convienient for storage medium such as magnetic tape to a certain extent
than disk.
Most compilers access files using this access method.

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.
When use of disk started for storing files, it became possible to read the bytes or records of a file
out of order. It is because; disks allow random access to any file block.
It also became possible to access records by its key instead of by position. Files whose bytes or
records can be read in any order are called random access files. They are required by many
applications such as database systems.

File Allocation Methods


There are various methods which can be used to allocate disk space to the files. Selection of an
appropriate allocation method will significantly affect the performance and efficiency of the system.
Allocation method provides a way in which the disk will be utilized and the files will be accessed.
There are following methods which can be used for allocation.
1. Contiguous Allocation: – Contiguous allocation is one of the most used methods for allocation.
Contiguous allocation means we allocate the block in such a manner, so that in the hard disk, all
the blocks get the contiguous physical block.
We can see in the below figure that in the directory, we have three files. In the table, we have
mentioned the starting block and the length of all the files. We can see in the table that for each
file, we allocate a contiguous block.

Advantages
1. It is simple to implement.
2. We will get Excellent read performance.
3. Supports Random Access into files.

Disadvantages
1. The disk will become fragmented.
2. It may be difficult to have a file grow.

Explain linked file allocation method. //2022 4 marks

2.Linked List Allocation


The linked list allocation method overcomes the drawbacks of the contiguous allocation method. In
this file allocation method, each file is treated as a linked list of disks blocks. In the linked list
allocation method, it is not required that disk blocks assigned to a specific file are in the contiguous
order on the disk. The directory entry comprises of a pointer for starting file block and also for the
ending file block. Each disk block that is allocated or assigned to a file consists of a pointer, and that
pointer point the next block of the disk, which is allocated to the same file.
Example of linked list allocation
We can see in the below figure that we have a file named ‘jeep.’ The value of the start is 9. So, we
have to start the allocation from the 9th block, and blocks are allocated in a random manner. The value
of the end is 25. It means the allocation is finished on the 25th block. We can see in the below figure
that the block (25) comprised of -1, which means a null pointer, and it will not point to another block.
File
|File Name |staring pointer|end pointer|

Write random -
Advantages
1. There is no external fragmentation with linked allocation.
2. Any free block can be utilized in order to satisfy the file block requests.
3. File can continue to grow as long as the free blocks are available.
4. Directory entry will only contain the starting block address.

Disadvantages
1. Random Access is not provided.
2. Any of the pointers in the linked list must not be broken otherwise the file will get corrupted.
3. Need to traverse each block.

3. Indexed Allocation
The Indexed allocation method is another method that is used for file allocation. In the index
allocation method, we have an additional block, and that block is known as the index block. For each
file, there is an individual index block. In the index block, the ith entry holds the disk address of the
ith file block. We can see in the below figure that the directory entry comprises of the address of the
index block.
Advantages of Index Allocation
1. The index allocation method solves the problem of external fragmentation.
2. Index allocation provides direct access.
3.
Disadvantages of Index Allocation
1. In index allocation, pointer overhead is more.
2. We can lose the entire file if an index block is not correct.
3. It is totally a wastage to create an index for a small file.

Directory Structure ://101%


Directories keep track of files. Directories are itself files in many systems.Systems store huge number of
files on large capacity disk.In order to manage all these data,we need to organize them.

Single-Level Directory:
Single-Level Directory is the easiest directory structure. There is only one directory in a single-level
directory, and that directory is called a root directory. In a single-level directory, all the files are present in
one directory that makes it easy to understand. In this, under the root directory, the user cannot create the
subdirectories.

Advantages :
1.It is simple to implement.
2. In a single-Level directory, the operations such as searching, creation, deletion, and updating can be
performed.

Disadvantages
If the size of the directory is large in Single-Level Directory, then the searching will be tough.
In a single-level directory, we cannot group the similar type of files.
Construct and explain directory structure of a file system in terms of two level and tree
structure.

Two-Level Directory
Two-Level Directory is another type of directory structure. In this, it is possible to create an individual
directory for each of the users. There is one master node in the two-level directory that include an
individual directory for every user. At the second level of the directory, there is a different directory
present for each of the users. Without permission, no user can enter into the other user’s directory.
Advantages of Two-Level Directory
1. In the two-level directory, various users have the same file name and also directory name.
2. Because of using the user-grouping and pathname, searching of files are quite easy.

Disadvantages of Two-Level Directory


1. In a two-level directory, one user cannot share the file with another user.
2. Another disadvantage with the two-level directory is it is not scalable.

Tree-Structured Directory
In a tree-structured directory, there is an own directory of each user, and any user is not allowed
to enter into the directory of another user. Although the user can read the data of root, the user
cannot modify or write it. The system administrator only has full access to the root directory. In
this, searching is quite effective and we use the current working concept. We can access the file
by using two kinds of paths, either absolute or relative.

Advantages of tree-structured directory

1. The tree-structured directory is very scalable.


2. In the tree-structures directory, the chances of collision are less.
3. In the tree-structure directory, the searching is quite easy because, in this, we can use both types of
paths, which are the absolute path and relative path.

Disadvantages of Tree-Structure Directory


1. In the tree-structure directory, the files cannot be shared.
2. Tree-structure directory is not efficient because, in this, if we want to access a file, then it may go under
multiple directories.

You might also like