0% found this document useful (0 votes)
9 views22 pages

unit6

Uploaded by

sanapanuj7
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)
9 views22 pages

unit6

Uploaded by

sanapanuj7
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/ 22

Chapter 6 File Management 10 Marks

Table of Contents
6.1 File .................................................................................................................................... 3
Attributes of the File ................................................................................................................ 3
Operations on the File ............................................................................................................ 3
File Type ................................................................................................................................. 4
Directory files ...................................................................................................................... 4
Special files ......................................................................................................................... 5
6.2 Access Methods ............................................................................................................... 6
File Access Mechanisms ........................................................................................................ 6
Sequential access................................................................................................................... 7
Direct/Random access............................................................................................................ 7
Indexed sequential access ..................................................................................................... 8
SWAPPING ............................................................................................................................ 8
FILE Allocation METHODS ..................................................................................................... 9
Contiguous Allocation ............................................................................................................. 9
Linked Allocation................................................................................................................... 10
Indexed Allocation ................................................................................................................ 10
6.3 Directory Structure .......................................................................................................... 11
Single Level Directory ........................................................................................................... 11

Operating System (Sub Code: 22516) Page 1 / 22


Two Level Directory .............................................................................................................. 12
Tree Structured Directory ..................................................................................................... 13
6.3 DISK ORGANIZATIONS AND DISK STRUCTURE ........................................................ 14
PHYSICAL STRUCTURE OF HARD DISK .......................................................................... 14
Logical Structure of a Hard Disk ........................................................................................... 16
RAID (Redundant Arrays of Independent Disks) .................................................................. 17
RAID 0 – Data Striping ......................................................................................................... 18
RAID 1 – Mirroring ................................................................................................................ 19
RAID 2 BIT STRIPING WITH PARITY ................................................................................. 19
RAID 3 Byte Striping with Parity ........................................................................................... 20
RAID 4 Block Striping with Parity .......................................................................................... 21
RAID 5 Block Striping with Distributed Parity ........................................................................ 21
RAID 6 Block Striping with Double Distributed Parity ........................................................... 22

Operating System (Sub Code: 22516) Page 2 / 22


6.1 File
A file is a named collection of related information that is recorded on secondary storage such
as magnetic disks, magnetic tapes and optical disks.
In general, a file is a sequence of bits, bytes, lines or records whose meaning is defined by the
files creator and user.

Attributes of the File


1. Name

Every file carries a name by which the file is recognized in the file system. One directory cannot
have two files with the same name.
2. Identifier

Along with the name, Each File has its own extension which identifies the type of the file. For
example, a text file has the extension .txt, A video file can have the extension .mp4.
3. Type

In a File System, the Files are classified in different types such as video files, audio files, text
files, executable files, etc.
4. Location

In the File System, there are several locations on which, the files can be stored. Each file carries
its location as its attribute.
5. Size

The Size of the File is one of its most important attribute. By size of the file, we mean the number
of bytes acquired by the file in the memory.
6. Protection

The Admin of the computer may want the different protections for the different files. Therefore
each file carries its own set of permissions to the different group of Users.
7. Time and Date

Every file carries a time stamp which contains the time and date on which the file is last
modified.

Operations on the File


There are various operations which can be implemented on a file. We will see all of them in
detail.

Operating System (Sub Code: 22516) Page 3 / 22


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. 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.
3. 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.
4. 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.
5. 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.
6. Truncate

Truncating is simply deleting the file except deleting attributes. The file is not completely deleted
although the information stored inside the file get replaced.

File Type
File type refers to the ability of the operating system to distinguish different types of file such as
text files source files and binary files etc. Many operating systems support many types of files.
Operating system like MS-DOS and UNIX have the following types of files −
Ordinary files
 These are the files that contain user information.
 These may have text, databases or executable program.
 The user can apply various operations on such files like add, modify, delete or even
remove the entire file.

Directory files
 These files contain list of file names and other information related to these files.

Operating System (Sub Code: 22516) Page 4 / 22


Special files
 These files are also known as device files.
 These files represent physical device like disks, terminals, printers, networks, tape drive
etc.
These files are of two types −
 Character special files − data is handled character by character as in case of terminals
or printers.
 Block special files − data is handled in blocks as in the case of disks and tapes.

File Types – Name, Extension

Operating System (Sub Code: 22516) Page 5 / 22


Root Directory

Directory 1
Directory2 Directory3

Sub
File1 File2
Directory

File3

File4

File Structure

6.2 Access Methods

File Access Mechanisms


File access mechanism refers to the manner in which the records of a file may be accessed.
There are several ways to access files −
 Sequential access
 Direct/Random access
 Indexed sequential access

Operating System (Sub Code: 22516) Page 6 / 22


Sequential access
A sequential access is that in which the records are
accessed in some sequence, i.e., the information in
the file is processed in order, one record after the
other. This access method is the most primitive one.
Example: Compilers usually access files in this
fashion.
• Fixed format used for records
• Records are of the same length
• Only the values of fields need to be stored
• Field name and length are attributes of the file
structure
• Key field Uniquely identifies the record
• Records are stored in key sequence

SEQUENTIAL FILE
• Optimal for batch applications if they involve the processing of all the records
• Easily stored on tape and disk
• Poor performance for interactive applications
• considerable processing and delay due to the sequential search of the file for a
key match

Direct/Random access
 Random access file organization provides,
accessing the records directly.
 Each record has its own address on the file
with by the help of which it can be directly
accessed for reading or writing.
 The records need not be in any sequence
within the file and they need not be in adjacent
locations on the storage medium.

Operating System (Sub Code: 22516) Page 7 / 22


Indexed sequential access
 This mechanism is built up on base of
sequential access.
 An index is created for each file which contains
pointers to various blocks.
 Index is searched sequentially and its pointer is
used to access the file directly.
 An index is added to support random access
 An index record contains a key field and a
pointer into the main file
 The index is a sequential file
 For searching
o Search the index to find the highest key
value that is equal to or precedes the
desired key value
o Search continues in the main file at the location indicated by the pointer

SWAPPING

A process can be swapped


temporarily out of memory to a
backing store, and then brought
back into memory for continued
execution

Operating System (Sub Code: 22516) Page 8 / 22


FILE Allocation METHODS
Files are allocated disk spaces by operating system. Operating systems deploy following three
main ways to allocate disk space to files.
 Contiguous Allocation
 Linked Allocation
 Indexed Allocation

Contiguous Allocation
 Each file occupies a contiguous
address space on disk.
 Assigned disk address is in linear
order.
 Easy to implement.
 External fragmentation is a major
issue with this type of allocation
technique.

Operating System (Sub Code: 22516) Page 9 / 22


Linked Allocation
 Each file carries a list of links to disk
blocks.
 Directory contains link / pointer to first
block of a file.
 No external fragmentation
 Effectively used in sequential access file.
 Inefficient in case of direct access file.

Indexed Allocation
 Provides solutions to problems
of contiguous and linked
allocation.
 A index block is created having
all pointers to files.
 Each file has its own index block
which stores the addresses of
disk space occupied by the file.
 Directory contains the
addresses of index blocks of
files.

Operating System (Sub Code: 22516) Page 10 / 22


6.3 Directory Structure
Directory can be defined as the listing of the related files on the disk. The directory may store
some or the entire file attributes.
To get the benefit of different file systems on the different operating systems, A hard disk can
be divided into the number of partitions of different sizes. The partitions are also called volumes
or mini disks.
Each partition must have at least one directory in which, all the files of the partition can be listed.
A directory entry is maintained for each file in the directory which stores all the information
related to that file.
A directory can be viewed as a file which contains the Meta data of the bunch of files.
Every Directory supports a number of common operations on the file:
1. File Creation
2. Search for the file
3. File deletion
4. Renaming the file
5. Traversing Files
6. Listing of files
To keep track of files, file systems normally have directories of folders.
Directories are system files for maintaining the structure of the file system.
1. Single Level Directory Structure
2. Hierarchical Directory
1. Two Level Directory Structure
2. Tree Level Directory Structure

Single Level Directory


The simplest method is to have one big list of all the files on the disk. The entire system will
contain only one directory which is supposed to mention all the files present in the file system.
The directory contains one entry per each file present on the file system.
• A single directory for all users

Operating System (Sub Code: 22516) Page 11 / 22


This type of directories can be used for a simple system.
Advantages
1. Implementation is very simple.
2. If the sizes of the files are very small then the searching becomes faster.
3. File creation, searching, deletion is very simple since we have only one directory.
Disadvantages
1. We cannot have two files with the same name.
2. The directory may be very big therefore searching for a file may take so much time.
3. Protection cannot be implemented for multiple users.
4. There are no ways to group same kind of files.
5. Choosing the unique name for every file is a bit complex and limits the number of files in
the system because most of the Operating System limits the number of characters used
to construct the file name.

Two Level Directory


In two level directory systems, we can create a separate directory for each user.

There is one master directory which contains separate directories dedicated to each user.
For each user, there is a different directory present at the second level, containing group of
user's file.
The system doesn't let a user to enter in the other user's directory without permission.

Operating System (Sub Code: 22516) Page 12 / 22


Characteristics of two level directory system
1. Each files has a path name as /User-name/directory-name/
2. Different users can have the same file name.
3. Searching becomes more efficient as only one user's list needs to be traversed.
4. The same kind of files cannot be grouped into a single directory for a particular user.

Tree Structured Directory


• In Tree structured directory system, any directory entry can either be a file or sub
directory.
• Tree structured directory system
overcomes the drawbacks of two level
directory system. The similar kind of
files can now be grouped in one
directory.
• Each user has its own directory
and it cannot enter in the other user's
directory. However, the user has the
permission to read the root's data but
he cannot write or modify this. Only
administrator of the system has the
complete access of root directory.
• Searching is more efficient in this
directory structure.

Operating System (Sub Code: 22516) Page 13 / 22


6.3 DISK ORGANIZATIONS AND DISK STRUCTURE

PHYSICAL STRUCTURE OF HARD DISK


PLATTERS
A hard drive contains a series of rotating platters
within a sealed case. The sealed case is known as
Head Disk Assembly, or HAD
SPINDLE
 Multiple platters are connected by a spindle.
• The spindle is connected to a motor which
rotates at a constant speed.
• The spindle rotates continuously until power is
removed from the spindle motor.
• Many hard drive failures occur when the spindle
motor fails
READ/WRITE HEADS
 Data is read and written by read/write heads, or R/W heads. Most drives have two R/W
heads per platter—one for each surface of the platter.
 If the drive malfunctions and a read/write head accidentally touches the surface of the
platter, it is called a head crash.
 A head crash generally results in data loss
ACTUATOR
Read/write heads are mounted on the actuator arm assembly, which positions the read/write
head at the location on the platter where data needs to be written or read
ACTUATOR ARM ASSEMBLY
The read/write heads for all of the platters in the drive in a drive are attached to one actuator
arm assembly and move across the platter simultaneously. Notice that there are two read/write
heads per platter, one for each surface
CONTROLLER
The controller is a printed circuit board, mounted at the bottom of the disk drive
Sectors and Tracks
 Data is recorded in tracks. A track is a concentric ring around the spindle which contains
information

Operating System (Sub Code: 22516) Page 14 / 22


 A track is divided into sectors
 Sectors typically hold 512 bytes of user data
CYLINDERS
A cylinder is the set of identical tracks on both surfaces of each of the drive’s platters
Hard Disk Performance
– Drives rotate at 60 to 250 times per second
– Transfer rate is rate at which data flow between drive and computer
– Positioning time (random-access time) is time to move disk arm to desired
cylinder (seek time) and time for desired sector to rotate under the disk head
(rotational latency)
Multiple disks connected to a
computer system through a
controller

• Disk interface standards families


– ATA (AT adaptor) range of standards
– SATA (Serial ATA)
– SCSI (Small Computer System Interconnect) range of standards
– SAS (Serial Attached SCSI)
– Several variants of each standard (different speeds and capabilities)

Operating System (Sub Code: 22516) Page 15 / 22


Logical Structure of a Hard Disk
Basically, we can divide the logical structure
of the hard disk in the following five logical
terms:
• MBR (Master Boot Record)
• It contains a small program to load and
start active (or bootable) partitions from hard
disk drives,
• It is also sometimes called as master
partition tables (MPTs).
• The MBR is located at Absolute Sector 0
or we can say at cylinder 0, head 0, and sector1.
• If there is more than one partition are present in the disk there are Extended Master Boot
Records, located at the beginning of each extended partition volume
• DBR (DOS Boot Record)
• After the partition table, the DOS Boot Record or sometimes called DOS Boot Sector is
the second most important information on your hard disk
• It contains some important information about disk geometry like
• Bytes Per Sector
• Sectors per Cluster
• Reserved Sectors etc.
• The job of the DBR is to load the operating system from the hard disk drive into the main
memory of computer and give the systems control to the loaded program.
• For doing this, the DBR contains a small program which is executed by the Master Boot
Record (MBR) Executable program.
• FAT (File Allocation Tables)
• A file allocation table (FAT) is a file system developed for hard drives that originally used
12 or 16 bits for each cluster entry into the file allocation table.
• It is used by the operating system (OS) to manage files on hard drives and other computer
systems.
• It is often also found on in flash memory, digital cameras and portable devices.
• It is used to store file information and extend the life of a hard drive.

Operating System (Sub Code: 22516) Page 16 / 22


• Types of FAT:
• FAT12
• FAT16
• FAT32
• Root Directory
• The Root Directory is like a table of contents for the information stored on the hard disk
drive
• The directory area keeps the information about the filename,
• Date and time of the file creation, file attributed file size and starting cluster of the
particular file
• The number of files that one can store on the root directory depends on the FAT type
being used
• Data Area
• The remainder of the volume after Root Directory is the Data Area
• The data area contains the actual data stored on the disk surfaces.
• When we format a hard disk the FORMAT command of DOS does not destroy or
overwrite the data on the data area.
• The FORMAT command only removes the directory entry and FAT entries and it does
not touch the actual data area.
• This makes the recovery of accidentally formatted hard disk drive possible

RAID (Redundant Arrays of Independent Disks)


RAID stands for Redundant Array of Inexpensive / Independent DISKS
1. In this system, because of failure of one disk data loss does not take place.
2. RAID is collection of various Disk organization techniques.
3. It is used to get better disk performance, reliability or more
4. RAID can be structured in many ways.
5. There are many levels of RAID such as RAID 0,1,2,3,4,5,6 10

Operating System (Sub Code: 22516) Page 17 / 22


DATA STRIPING

Data Striping is the


technique of splitting data for
spreading the data across
multiple Hard Drives
This division of data can be
done at 3 Levels:
1. Bit Level
2. Byte Level (1 Byte=8 bits)
3. Block Level (Group of
Number of Bytes)

RAID 0 – Data Striping

• Block Level Data Striping


• Fault Tolerance: None
• Performance: Fastest
• Storage Space: 100 %

Operating System (Sub Code: 22516) Page 18 / 22


RAID 1 – Mirroring
 Mirroring means data is written
identically to two drives (mirrored
set).
• Requires at least 2 Disks.
• Fault Tolerance: Mirrored Set
• Performance: 50%
• Storage Space: 50%

RAID 2 BIT STRIPING WITH PARITY

 Bit Level Data Striping is used at this level.


 It consists of splitting the bits of each byte across multiple disks.

Operating System (Sub Code: 22516) Page 19 / 22


 RAID 2 uses parity
 Parity is the simplest technique for detecting & Error correcting Errors.
 It uses an extra disks for storing all the parity information.
 It has not implemented accurately and is rarely used

RAID 3 Byte Striping with Parity

• Byte Level
Striping along with
parity is used at
this level.
• It uses an extra
disks for storing all
the parity
information.
• If any drive gets
failed, the parity
restores the failed
disk.
If parity drive fails
fault tolerance is
not possible

Operating System (Sub Code: 22516) Page 20 / 22


RAID 4 Block Striping with Parity

• Block Level Striping along


with parity is used at this level.
• It uses an extra disk for
storing all the parity
information.
• If any drive gets failed, the
parity restores the failed disk.
If parity drive fails fault
tolerance is not possible

RAID 5 Block Striping with Distributed Parity

• Block Level Striping along


with parity is used at this level.
• It requires at least 3 Hard
Disks.
• Fault Tolerance: Parity (You
can handle 1 Disk Failure)
• Performance: Fast
• Storage Space: 75 %
(Loose 1 Hard Disk Space)

Operating System (Sub Code: 22516) Page 21 / 22


RAID 6 Block Striping with Double Distributed Parity

• Block Level Striping with Double Distributed Parity


• Used where high availability (24 x 7) is required such as Google, Facebook.
• It is enhanced version of RAID 5
• Fault Tolerance: Parity (You can handle 2 Disk Failure)
• Performance: Fast
• Storage Space: Loose 2 Hard Disk Space

CONCLUSION:
• Redundant Array of Independent Disks
• RAID 0- Data Striping
• RAID 1- Mirroring
• RAID 2- Bit Level Data Striping + Parity
• RAID 3- Byte Level Data Striping + Parity
• RAID 4- Block Level Data Striping + Parity
• RAID 5- Block Level Distributed Parity Bit
• RAID 6- Block Level Double Distributed Parity Bit

Operating System (Sub Code: 22516) Page 22 / 22

You might also like

pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy