Академический Документы
Профессиональный Документы
Культура Документы
Information used by a computer system may be stored The operating system provides a mapping between
on a variety of storage mediums(magnetic disks, mag- the abstract logical units of storage, that is a file, and
netic tapes, optical disks, etc). the physical storage device.
Doom
stars
1 2
A layered approach is often used in implementing this A file is a named collection of related information.
mapping. The layers are:
Files consists of a sequence of bits, bytes, lines, or
lower levels — physical properties of the storage records.
device,
The information in a file is generally defined by its cre-
ator.
intermediate levels — map the logical file con-
cepts into physical device properties, and
There is numerous types of files. These include: Typically the operating system will keep track of the
text, following attributes for each file:
source, name,
object, type,
executable, location,
binary, size,
compressed, protection,
A file is an abstract data type. The operating system Rather than the operating system constantly search-
will provide a set of routines to uniformly view/manipulate ing the directory for each operation that is performed
this data type. A basic set of routines includes:
on file. Files are generally opened and information
creation, about the file is stored in the open file table. Then all
file operation are performed using an index to this ta-
writing,
ble. The process will close the file once the interaction
reading, with the file is complete.
repositioning,
deletion,
truncating,
appending, and
renaming.
The information in the open file table includes : Types are supported to a variety of extents by different
operating systems.
file pointer,
MS-DOS — recognises file extensions.
9 10
Two basic approaches are used to access files: The file system may be divided into partitions. Each
partition will have a directory structure.
create a file,
Direct access.
delete a file,
11 12
Single-Level Directory Files Two-Level Directory Files
marks marks
rank rank
graph1 graph1
graph2 graph2
test
test
Jack
Jill
marks
Jim rank
graph1
ass1
rank
game1
game2
test
13 14
marks marks
rank rank
graph1 graph1
graph2 graph2
test test
Jack Jack
Jill Jill
marks marks
graph1 themail
bin bin
var ls var ls
rm rm
cp cp
log log
sent sent
mail mail
received received
error error
log log
15 16
General Graph Directories Files Protection Files
graph1
cess.
graph2
Jack
test
The types of access a user may be either granted or
Jill denied includes:
marks
rank
home
themail
read,
bin
var ls write,
rm
cp execute,
log append,
sent
mail
received
error delete, and
log
var
list.
Approaches to provide file protect include : Some of the problems of access lists may be over-
come by providing a condensed version of the access
list. For each file the operating systems considers
Access lists — each file has a list of users and
three types of users:
how they may access the file, and
User — the user who created and owns the file.
Passwords — a user must provided a password Group — the set of users that belong to group for the file.
19 20
Protection Files Magnetic Disk Files
Spin
21 22
The designer of a file system must: The allocation method determines how a file will be
stored on the disk. It’s view of a disk is a set of fixed
sized blocks.
determine how the file system should look to the
user, and
A block consists of one or more sectors.
design algorithms and data structures that map The main problem is how to allocate the disk space to
the logical files into the physical storage devices. the files such that the disk space is utilised effectively
and files can be accessed quickly.
The file system must allow the data to be stored, lo- There are three major approaches:
cated, and retrieved easily.
contiguous,
linked, and
indexed.
23 24
Contiguous Files Contiguous Files
The contiguous allocation method places files in a set Accessing a file that has been allocated contiguously
of contiguous blocks on the disk. is easy. However, find space for a new file is more
difficult.
directory disk
report 1 2
0 1 2 3
What if there is only alot of small contiguous free
test 14 5
holes?
4 5 6 7
8 9 10 11
12 13 14 15
How big will the new file be?
16 17 18 19
25 26
report 1 2
Simulations have show that both first-fit and best-fit
test 14 6 0 1 4 2 -1 3 10
are better than worst-fit.
4 10 5 6 -1 7
8 10 6
These approaches suffer from external fragmentation. 9 11 3
If a process wishes to access the ’th block it must fol-
low the pointers which requires this many disk Note that, cluster will increase the internal fragmenta-
reads. tion. This problem may be very bad if there are many
small files.
29 30
The main advantage of this approach is that direct ac- file index block
block 0 block 16
report 0
14
cess is improved, as the location of any block within a test 16 0 1 2 3
1
4 11
2 3
file can be found using the FAT. 4
8
5 6 7
-1
-1
10
6
9 10 11
-1 -1
12 13 14 15 -1 -1
16 17 18 19
31 32
Indexed allocation Files Indexed allocation Files
a linked scheme,
a multilevel index, or
combined scheme.
Direct Block 0
grows. This is transparent to the user.
Direct Block 1
:
Direct Block 11
Example. Unix used an inode block which contains:
Single Indirect
35 36
Free-Space Management Files Free-Space Management Files
The free space list records all the disk blocks that are Approaches used to keep track of the free space in-
free. As a file grows or a new file is created the free cludes:
list is used to find available disk blocks. When files are
deleted or truncated then their blocks are return to the
bit vector
free list.
The free list implementation must also consider effi- linked list
ciency and performance.
grouping
counting
37 38
A variety of techniques may be used to improve the ef- A disk cache may be used to reduce the number of
ficiency and performance of secondary storage. Some actual reads and writes to the disk.
examples are:
Disk caches may use different replacement algorithms
depending on the type of file accessed. An example
UNIX allocation and free-space algorithms try to
of this is the use of sequential accessed files may be
keep a file’s data block near that file’s inode block
improved by using free-behind and read-ahead tech-
to reduce seek time.
niques. In free-behind once a block is written past or
read pasted it will not be accessed again and hence
BSD UNIX varies the cluster size as a file grows. it may be replaced. Also blocks may be read before
they are access so they are in the cache when the
sequential access gets to them.
39 40
Recovery Files
41