Professional Documents
Culture Documents
OS Chapter 5
OS Chapter 5
(a) A segmented process before mapping files into its address space.
(b) The process after mapping an existing file abc into one segment and creating a
new segment for file xyz.
• Here a process can copy the source segment into the
destination segment using an ordinary copy loop. No
read or write system calls needed. Then it can
execute the unmap system call to remove the files
from the address space and then exit.
Advantage: eliminates the need for I/O thus making
programming easier.
Disadvantage:
• It is hard for the system to know the exact length of
the output file and there is no way of knowing how
many bytes in that page were written
• The system has to take great care to make sure the two
processes do not see inconsistent versions of the file.
• A file may be larger than a segment, or even larger
than the entire virtual address space.
DIRECTORIES:
To keep track of files, file systems normally have
directories or folders
a. Single-Level Directory Systems:
• The simplest form of directory system is having
one directory containing all the files. Sometimes it
is called the root directory. Ex. CDC 6600, early P.C.
• Below diagram illustrates one directory system,
• Advantage is simplicity and ability to locate files
quickly.
A single-level directory system containing four files, owned by three
different people, A , B , and C .
DIRECTORY OPERATION:
The allowed system calls for managing directories
are:
1. Create 2. Delete 3. Opendir 4. Closedir 5.Readdir
6. Rename 7. Link 8.Unlink
FILE SYSTEM IMPLEMENTATION
File System Layout:
• Sector 0 of the disk is called the MBR (Master Boot
Record) and is used to boot the computer. The end of
the MBR contains the partition table. This table gives
the starting and ending addresses of each partition.
• MBR program locates the active partition, read in its
first block, called the boot block , and execute it.
• The program in the boot block loads the operating
system contained in that partition.
• The layout of a disk partition varies from file system
to file system. Often the file system will contain some
of the items shown in below Figure.
• The first one is the superblock. It contains all the
key parameters about the file system like file
system type, the number of blocks in the file
system, and other key administrative Information
and is read into memory when the computer is
booted.
• Free space mgmt block tells about free blocks in the
file system.
• i-nodes tells all about the file.
• Root directory contains the top of the file system tree.
• The remainder of the disk typically contains all the
other directories and files.
Implementing Files:
• Various methods are used in different operating
systems to keep track of files put in respective blocks.
• Some of methods are: 1. Contiguous allocation 2.
linked list allocation 3. linked list allocation using
table in memory. 4. i-node
1. Contiguous allocation- stores each file as
contiguous run of disk blocks.
2. Linked List Allocation- files are placed as linked
list of disk blocks. The first word of each block is
used as pointer to next one, rest of block is used
for data.
3. Linked List Allocation Using a Table in Memory-
table in main memory called FAT (File Allocation
Table ) is maintained and it contains a list of
pointer to each disk block.
4. i-none- lists the attributes and disk addresses of
the files blocks
BACKUP STRATEGIES:
• Backing up of files can be done on modern tapes.
• Modern tapes hold tens or sometimes even
hundreds of gigabytes
Backups are done to:
1. Recover from disaster – accidents like disk crash,
fire, flood or some natural catastrophe
2. Recover from stupidity – accidentally removing
files.
Few issues in backing up data’s are:
• Should the entire file system be backed up or only
part of it?
• Should the files that were backed up before also
must be backed up again. backing up files that have
not changed since the last backup leads to the idea
of incremental dumps
• Should the data’s be compressed to save some
space before backing up is made
• How should the backup on active file system has to
be made.
• Will backing up lead to non technical problems like
security problems related to data’s.
• Strategies used for back up are:
1. Physical dump
2. Logical dump
• A physical dump starts at block 0 of the disk, writes
all the disk blocks onto the output tape in order,
and stops when it has copied the last one.
• A logical dump starts at one or more specified
directories and recursively dumps all files and
directories found there that have changed since
some given base date