Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
File Management
Fall 2014
File Operations
Create
creates a new file and adds it to the directory
Delete
remove from the directory and destroyed
Open
allows a process to perform functions on the file
Close
the process is no longer allowed to operate on the file
Read
read all or a portion of the file
Write
add new data or change existing data in the file
3
File Structure
Field:
Basic element of data
Contains a single value
Characterized by its length and data type
Can be fixed length or variable length
Record:
Collection of related fields
Treated as a unit
Example: employee record
Can be variable length if some of the fields are variable
length, or if the number of fields may vary
4
File Structure
File
Collection of similar records
Treated as a single entity
Have unique file names
May restrict access
Database
Collection of related data (one or more files)
Relationships exist among elements
Managed by separate DBMS
Unix Files
Unix files are simply streams of bytes and do not have
internal structure as far as the operating system is
concerned.
Some OSs such as mainframe systems provide various file
structures the application can use.
Objectives for a
File Management System
Meet the data management needs and requirements of the
user (described on next slide).
Guarantee that the data in the file are valid.
Optimize performance.
Provide I/O support for a variety of storage device types.
Minimize or eliminate the potential for lost or destroyed
data.
Provide a standardized set of I/O interface routines
Provide I/O support for multiple users.
12
14
16
Pile
17
18
Sequential File
20
21
22
Indexed File
24
25
B-Trees
Indexes are often implemented as B-trees.
The B-tree will have a large branching factor resulting in a
tree of low height.
This results in fewer disk accesses to traverse the tree in a
search.
26
Directories
The directory contains information about the files,
including attributes, location, and ownership.
The directory is itself a file, owned by the OS and
managed by the file management system.
The next slides give information typically found in the
directory for each file.
27
28
29
Directory Operations
Search: find a file in the directory.
Create file: add entry to directory when a file is created.
Delete file: remove entry from directory when file is
deleted.
List directory: all or a portion may be listed.
Update directory: change file attributes stored in directory.
30
Directory Structure
A tree-structure is used for storing the file directory.
At the top is the master directory, beneath it are each user
directory.
Every level may contain files and subdirectories.
31
Directory Naming
Users refer to files by their symbolic names.
Each name must be unique.
In a tree structure, the path to the file helps eliminate
duplicate name problems.
Most systems provide for a working directory, where file
names can be specified relative to it.
Users typically have a default, or home, directory upon
logging in.
32
File Sharing
In a multiuser system, files should be able to be shared
between users.
This presents two issues:
Access rights
Simultaneous access
33
34
35
37
Record Blocking
Users work with a logical view of a file as a set of records.
The I/O device works with the physical view of a file as a
set of blocks.
Blocking of records is performed when writing data,
unblocking is performed when reading data.
38
Record Blocking
Blocking considerations:
The larger the block, the more records that are passed in a
single I/O.
For sequential access this reduces I/Os, but may result in
unnecessary data transfer for random access.
Typically blocks are of fixed length to simplify the I/O
transfer.
39
Record Blocking
There are three blocking methods:
Fixed: fixed-length records. May cause internal
fragmentation.
Variable-length spanned: variable-length records
which may span blocks. Permits unlimited record size.
May require multiple I/Os.
Variable-length unspanned: variable-length records
which do not span blocks. May cause internal
fragmentation.
40
41
42
File Allocation
File allocation issues:
Whether to allocate the maximum space required all at
once, or to allocate space in portions.
If portions are used, how big should a portion be?
If portions are used, how to keep track of the portions.
43
44
46
47
48
49
50
51
52
End of Slides
54