0% found this document useful (0 votes)
16 views40 pages

Topic 5

Caching stores frequently accessed files in high-speed memory to improve access speed. When a process requests a file, the file system first checks the cache for the data before accessing the hard disk. If the data is in cache it can be accessed much faster than from disk, improving performance. Caching also reduces disk access which improves throughput and reduces disk wear. Caching algorithms determine which files to remove from cache to make space for new files as needed.

Uploaded by

Kalai Shan
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)
16 views40 pages

Topic 5

Caching stores frequently accessed files in high-speed memory to improve access speed. When a process requests a file, the file system first checks the cache for the data before accessing the hard disk. If the data is in cache it can be accessed much faster than from disk, improving performance. Caching also reduces disk access which improves throughput and reduces disk wear. Caching algorithms determine which files to remove from cache to make space for new files as needed.

Uploaded by

Kalai Shan
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/ 40

CHAPTER 5

FILE MANAGEMENT
LEARNING OUTCOME
At the end of this chapter, students will be able to:
 Identify the basic function of file system
 Describe file organization technique
 Describe types of file structure
 Identify the methods of file allocation
INTRODUCTION

 File management system can be define as a system


that an operating system uses to keep track of different
files.

 Consists of system utility programs that run as


privileged applications.

 File management aims to provide a convenient


programming environment for the users of the system.

 Output is saved in a file for long-term storage.


INTRODUCTION

 There are several functions that must be performed


by an efficient file system:

✓ include storing of files in an orderly fashion


✓ accessing the stored files
✓ appending the stored files and protecting the files
from loss of data.
FILES – A CONCEPT
 A file could be defined as contiguous set of words
(bits, bytes or instructions)
 Can store different kinds of information in a file; for
example source codes, images, text documents, and
so forth.
FILES - ATTRIBUTES
 A file has various attributes like name, type, location, size,
protection, time and data of creation, user information etc.
FILES - ATTRIBUTES
 Name -
 symbolic file-name, only information in human-readable form

 Type -
 for systems that support multiple types

 Location -
 pointer to a device and to file location on device

 Size -
 current file size, maximal possible size

 Protection -
 controls who can read, write, execute

 Time, Date and user identification


 data for protection, security and usage monitoring

 Information about files are kept in the directory structure,


maintained on disk
FILE NAMING
File naming=File name + File
extension
Eg. Student.doc
In this example the Student is the
file name and doc is the file
extension
FILE NAMING
FILE OPERATIONS

 Creating a file - A blank file is created


 Writing a file - To write some data on file.
 Reading a file - When a file is only to be read.
 Opening a file - Open a file either for reading
or writing.
 Closing a file - When a file is no longer
accessed.
 Deleting a file - The purpose of this system
call is to delete this file
FILE SYSTEM
 There are three major file systems supported by
Microsoft Windows:

✓ FAT
✓ FAT32
✓ NTFS
FILE ORGANIZATION
 The Pile
 Data are collected in the order they arrive
 Purpose is to accumulate a mass of data and save it
 Records may have different fields
 No structure
 Record access is by exhaustive search
FILE ORGANIZATION
 The Sequential File
 Fixed format used for records
 Records are the same length
 All fields the same (order and length)
 Field names and lengths are attributes
of the file
 One field is the key filed
 Uniquely identifies the record
 Records are stored in key sequence
 New records are placed in a log file or transaction
file
 Batch update is performed to merge the log file with
the master file
FILE ORGANIZATION

 Direct or Hashed File


 Directly access a block at a known address
 Key field required for each record
FILE ORGANIZATION

 Indexed Sequential File


 Index provides a lookup capability to quickly reach
the vicinity of the desired record
 Contains key field and a pointer to the main file
 Indexed is searched to find highest key value that
is equal to or precedes the desired key value
 Search continues in the main file at the location
indicated by the pointer
FILE ORGANIZATION
 New records are added to an overflow file
 Record in main file that precedes it is updated to
contain a pointer to the new record
 The overflow is merged with the main file during a
batch update
 Multiple indexes for the same key field can be set
up to increase efficiency
FILE ORGANIZATION

 Partition
 Disk can be subdivided into partitions
 Disk or partition can be used raw – without a file system, or
formatted with a file system
 Partitions also known as minidisks, slices
 Entity containing file system known as a volume
 Each volume containing file system also tracks that file
system’s info in device directory or volume table of contents
FILE ORGANIZATION
 Partition
FILE STRUCTURE

 The four most common file structures :

a) Unstructured (Byte Sequence)


b) Structured - Record Sequence Structure (fixed
record)
c) Structured - Record Sequence Structure (variable
record size)
d) Complex Structure (Tree)
FILE STRUCTURE

Sequence Sequence Tree


of bytes of records of records
20
FILE STRUCTURE
 Unstructured (Byte Sequence)
 Read or write a number of bytes
 User program decides meaning

 Structured - Record Sequence Structure (fixed


record)
 Collection of bytes treated as a unit.
 Fixed length
 Read or write a one of record at a time
 Punch cards, 80 char records, employee record.
FILE STRUCTURE
• Tree
• Records with keys
• Read, insert, delete a specific record
• Still used on mainframe computers in some
commercial data processing
FILE ALLOCATION
 There are 3 methods of file allocation which are:
 Contiguous file allocation
 Linked list non-contiguous (using blocks)
 Linked list non-contiguous allocation (using index)
CONTIGUOUS ALLOCATION
 Is the simplest allocation scheme
 Store file as contiguous block (One file is stored after)
 Advantages
 Simple to implement
 Faster data reading
 Disadvantages
 Disk fragmentation
 Not used in commercial OSs but suitable for
Embedded OSs & CD-ROMs
 External fragmentation will occur
 Need to perform compaction
BLOCK SIZE
 For the easy of addressing & reading/writing data
are access as fixed size blocks.
 A single block can vary from the size of a single
sector to multiple sector
 It should neither be too low nor large
 4k is a good value
 Block size:
 Higher block size -> Higher data rate
 Higher block size -> Lower space utilization
 Lower block size -> Lower data rate
 Lower block size -> Higher space utilization
LINKED LIST ALLOCATION USING BLOCKS
 Files kept as a linked list of disk blocks
 First word of each block points to the next block
 Only the address of the block appears in the
directory
entry
 No disk fragmentation
 Random access is extremely slow
 Easy to use - no estimation of size necessary
LINKED LIST ALLOCATION USING BLOCKS
 Simple, only needs the starting block address
 No external fragmentation
 Easy to create a file
 Needs more space for the pointers
 Sequential access only, no random access
 Links are in many parts of the disk, a reliability
 problem
 MS-DOS and OS/2 use disk-space allocation
through a file-allocation table (FAT)
LINKED LIST ALLOCATION USING BLOCKS
LINKED LIST ALLOCATION USING AN INDEX
 Indexed allocation
 File allocation table contains a separate one-level
index for each file
 The index has one entry for each portion allocated
to the file
 The file allocation table contains block number for
the index
Brings all pointers together into the index block.
▪ Need index table
▪ Supports sequential, direct and indexed access.
▪ Dynamic access without external fragmentation, but
have overhead of index block.
LINKED LIST ALLOCATION USING AN INDEX
Index Nodes
 Index can be used to provide
 fault tolerance,
 capacity
 performance.
 Basically you create a “matrix” of index servers. The more
rows you create, the more fault tolerance you provide. The
more columns, the more content is created and the better
performance will be realized. Below is a diagram depicting
the Index server matrix (a node is the same thing as a
server).
The level
Index node environment
Real life
Task
Explain How Caching Enhances
File System Performance

You might also like