0% found this document useful (0 votes)
5 views10 pages

Operating System File Management

Uploaded by

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

Operating System File Management

Uploaded by

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

The Launcher Academy

Class By: K.K. Singh


Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.

File Management
Computer can store information on different storage media, such as magnetic disks, tapes,
compact disks. The physical storage is converted into logical storage unit by the operating system,
the logical storage unit is said to be the file.

A file is a collection of related information that is recorded on secondary storage.

FILE OPERATION:
The basic operations on the files are:
Creating the file: Two step to create a file. First check whether the space is available or
not. If the space is available the made an entry for new file in the directory. The entry
includes name of the file, path of the file etc.
Writing a file: To write a file, we have to know two things one is the name of the file
second the information or data to be written in the file, the system searches the given
location for the file. If the file is found, the system must keep a write pointer to the
location in the file where the next write is to take place.
Reading the file: To read a file first of all we search the directories for the file, if the file is
found, the system keeps a read pointer to the location in the file where the next read is to
take place.
Repositioning within the file: this file operation is also called file seek. In this operation
generally we perform both read and write operation by moving read/write pointers to a
specified location within the file.
Deleting a file: To delete a file, first of all search the directory for named file, then release
the file space and erase the directory entry.
Truncating a file: To truncate a file, remove the file content only, but attributes are as it is.

File Attribute
Name: Every file must be recognizes by name so it is an compulsory attribute which
distinguishes a file from another file. A name is a string that is a collection of characters.

Type: A file can be of any type and the type of a file can be identified by its extension.

Location: A file location attribute describes where the file is stored in which drive or
directory.

Size: This property describes the current size of the file in bytes.

Protection: It provides the access control information. It control who can read/write and
execute a file.

Time/Date: It specifies the time and date of creation of a particular file.

File Access Methods

File store information, this information must be accessed and read into the computer memory.
There are several methods to access information from the file.
The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.

Sequential Access
Direct Access

Indexed Sequential Access

Sequential file Access: It is one of the simplest method in which the information in the file
is processed in sequential order, one record after another. Magnetic tape supporting this
type of file accessing method.

For Example: a file consisting of 100 records, the current position of read/write head is at
45th record. Suppose we want to read the 75th record then it access sequentially form
45,46,47… 75. So the read/write head traverse all the records between 45 to 75.

Direct file Access: In this method records can read/write randomly without any order. The
direct method based on a disk model of a file, because disks allow random access to any
file block. A direct access allows arbitrary blocks to be read or written. For example
A disk consisting 256 blocks, the current position of read/write head is at 95th block. The
block to be read/written is 250th block. So the head can directly moved to the 250 block
to perform read/write operation. For example CD containing 10 songs we can select any
song arbitrar y to listen.

Indexed Sequential Access:


Let us suppose, a file consisting of 60,000 records, the master index divide the total
records in to 6 blocks, each block consisting of a pointer to the secondary index. The
secondary index divides the 10,000 records into 10 indexes. Each index consisting of a
pointer to its original location. Each record in the index file consisting of two fields. A key
field and a pointer field. Suppose we want to access 55,550th record, the file management
system access the index that is 50,000 to 60,000, this block consisting of a pointer points
to the 6th index in the secondary index. This index points to the original location of
record from 55,000 to 56,000. From this it follows the sequential method so it is also
called indexed sequential file access method.
The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.
DIRECTORY STRUCTURE

Single level Directory Structure


Two Level Directory Structure
Hierarchical Directory Structure

Single Directory Structure: It is simplest of all directory structure, in this directory system
only one directory stores all the files in the system called root directory. The advantage of
But main disadvantage is this system cannot be used in multiuser system, because multiuser
system requires directory for each uses to provide the security. Again name confliction problem
that is only unique name files can be store in a single directory.

Two Level Directory Structure:


The main problem in single level directory structure is different users may be accidently use the
same names for their files. To avoid this problem, each user needs a private directory. In this way
names chosen by one user do not conflict with the name chosen by other users.
In this system users can have their own directory inside the root directory called subdirectory.
this method is it is simple to implement and can locate the file quickly.

Hierarchical directory System:


The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.
Protection
When information is stored in a computer system, we want to keep it safe from improper access.
So there is a need of some protection mechanism. Protection mechanisms provide controlled access by limiting the
types of file access that can be made. Access is permitted or denied depending on several factors, one of
which is the type of access requested. Several different types of operations may be controlled:

• Read- Read from the file.


• Write- Write or rewrite the file.
• Execute- Load the file into memory and execute it.
• Append- Write new information at the end of the file.
• Delete- Delete the file and free its space for possible reuse.
• List- List the name and attributes of the file.

The most common approach to the protection problem is to make access dependent on the identity of the user.
Different users may need different types of access to a file or director y. The most general scheme to implement identity
dependent access is to associate with each file and directory an access-control list (ACL) specifying user names and
the types of access allowed for each user. When a user requests access to a particular file, the operating system checks
the access list associated with that file. If that user is listed for the requested access, the access is allowed.
Otherwise, a protection violation occurs, and the user job is denied access to the file. This approach has the advantage of
enabling complex access methodologies.
The main problem with access lists is their length. If we want to allow everyone to read a file, we must list all users with
read access. This technique has two undesirable consequences:

Constructing such a list may be a tedious and unrewarding task, especially

if we do not know in advance the list of users in the system. The directory entry, previously of fixed size, now needs to
be of variable size, resulting in more complicated space management. These problems can be resolved by use of a
condensed version of the access list. To condense the length of the access-control list, many systems recognize
three classifications of users in connection with each file:
• Owner. The user who created the file is the owner.
• Group. A set of users who are sharing the file and need similar access is a group, or work group.
• Universe. All other users in the system constitutes the universe.
Another approach to the protection problem is to associate a password with each file. Just as access to the computer system
is often controlled by a password, access to each file can be controlled in the same way. If the passwords are chosen
randomly and changed often, this scheme may be effective in limiting access to a file. The use of passwords has
a few disadvantages, however. First, the number of passwords that a user needs to remember may become large,
making the scheme impractical. Second, if only one password is used for all the files, then once it
is discovered, all files are accessible.

Access Matrix
A process operates within a protection domain, which specifies the resources that the process may access. Each domain defines

a set of objects and the types of operations that may be invoked on each object. The ability to execute an operation on an

object is an access right. A domain is a collection of access rights, each of which is an ordered pair <object-name,rights-set>.

For example, if domain D has the access right <file F,{read,write} >,then a process executing in domain D can both read and write
file F; it cannot, however, perform any other operation on that object.

For example

we have three domains: D1, D2,and D3. The access right <O4,(print}> is shared by D2 and D3, implying that a process

executing in either of these two domains can print object O4. Note that a process must be executing in domain D1 to

read and write object O1 while only processes in domain D3 may execute object O1. The protection can be viewed

abstractly as a matrix, called an access matrix. The rows of the access matrix represent domains, and the columns
The Launcher Academy
Class By: K.K. Singh
Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.
Office NO- 17/18, 2nd
represent objects. Each entry in the matrix consists of a set of access rights.

Here given an example There are four domains and four objects—three files ( F1, F2, F3) and one laser printer.

A process executing in domain D1 can read files F1 and F3. A process executing in domain D4 has the same privileges as one
executing in domain D1 but in addition, it can also write onto files F1 and F2 Note that the laser printer can be accessed only
by a process executing in domain D2.

File System Structure


To provide efficient and convenient access to disk, the O.S imposes one or more file systems to allow the data to be
stored ,located and retrieve easily. The file system composed of many different levels.
Application program
|
Logical file system
|
File organization module
|
The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.
Basic file system
|
I/O control
|
Devices

Logical file system: logical file system manages metadata information. Metadata includes all the file
system structure except the actual data. It maintains file structure via FCB (file control block) which
contains information about the file including ownership, permissions and location of the file contents.
File organization module: it knows about files and their logical blocks, as well as physical blocks. It
can translate logical block addresses to physical block addresses to transfer the files.
Basic file system: it issues commands to the appropriate device driver to read and write physical block
on the disk.
I/O control: it consist of device drivers and interrupt handler to transfer the information between main
memory and the disk.

File allocation methods:


Files are normally stored on the disks, so the main problem is how to allocate space to these files so that
disk space is utilized effectively and files can be accessed quickly.
There are three methods to allocating disk spaces:
1. contiguous allocation
2. linked allocation
3. indexed allocation or grouped allocation

1. Contiguous allocation: in this allocation method each file occupies a set of contiguous blocks on the
disk. For example : a 100 kb file would be allocated 100 consecutive blocks.
File allocation table:
File name start length
A 21 5
B 3 10
C 35 7
The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.

Advantage:
1. It reduces the files access time because files are accessed sequentially as their contents are stored in
continuous block that is there is no need of lengthy seeks.
Disadvantage
1. It is difficult to find the contiguous free blocks in the disk.
2. Another problem is external fragmentation; it means some free blocks could happen between two
files.

2. Linked allocation: In this allocation method, each file is a linked list of disk blocks, the disk block may
be scattered anywhere on the disk.
The directory contains a pointer to the first and the last blocks of the file.
File allocation table
File name start block end block
xyz 9 25

Advantage:
1. External fragmentation problem can be solved using this allocation method.
Disadvantage:
The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.
1. The pointer itself takes some memory with into a block.
2. It takes much accessing time.

3. Indexed allocation: In these allocation methods, all the pointers that pointing to all the blocks of a file
are stored in a block called index block.Each file has its own index block, which is an array of disk
block addresses. The ith entry in the disk block points to the ith block of the file. The directory
contains the address of the index block. To find and read the ith block, we use the pointer in the ith
index block entry.

FAT
File index block
9
Xyz 19
6
19 1

Free space management:


To keep track of free disk space, the system maintains a free space list. This list records all the free disk
blocks those are not allocated the other files. To create a file, the system searches the free space list for
the required amount of space to the new file. If space is available the system uses those free spaces to
store the file and these spaces are then removed from the free space list. When a file is deleted, its disk
space is added to the free space list.
1. Bit vector: free space list is implemented as a bit map or bit vector. Each block is represented by 1 bit.
If the block is free, the bit is 1, if the block is allocated, the bit is 0.
Ex: consider disk blocks 2,3,4,5,8,9,10,11,12,13,17,18,25,26 and 27 are free and the rest of the blocks
are allocated. Bit map would be 00111100111111000110000001110000….
The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.
2. Linked List: In this method, all the free disk blocks are linked together; a pointer to the first free
block is stored in a special location on the disk. The first block contains a pointer to the next free
block and so on.

3. Grouping: In this method, the first free block stored the addresses of n free blocks. The first n-1 of these
blocks is actually free. The last block (nth) contains the addresses of another n free block and so on.
4. Counting: In this free space management technique, it keeps the address of first free block and the number
N of free contiguous blocks that follow the first block.
The Launcher Academy
Class By: K.K. Singh
Office NO- 17/18, 2nd Floor, City Center Opposite – Gossner College, Club Road, Ranchi, Contact No. 8877155769, 7903154392.

You might also like