Looks like no one added any tags here yet for you.
List the desirable properties of files
Long term existence
kept on secondary storage
Sharable between processes
Structure
internal structure of file so it can be organized to be suitable for certain applications
File structure: What is a field?
Basic element of data
contains a single value
characterized by its length and data type
can be fixed length or variable length
File structure: What is a record?
collection of related fields
treated as a unit
can be variable length if some fields are variable length or if number of fields vary
File structure: What is a file?
a collection of similar records
treated as a single entity
have unique file names
may restrict access
File structure: What is a database?
collection of related data (one or more files)
relationships exist among elements
managed by separate DBMS
Do UNIX bytes have internal structure?
No, they’re just streams of bytes
What is a file management system?
set of system software providing file services to users and applications
programmer does not need to develop file management software for each application
Objectives for a file management system
Meet the data management needs and requirements of the user
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 of destroyed data
provide a standardized set of I/O interface routines
Provide I/O support for multiple users
User requirements for file management system
Should be able to create, delete, read and change files
May have controlled access to other users’ files.
May control what type of accesses are allowed to the user’s files.
Should be able to restructure the user’s files in a form appropriate to the problem.
Should be able to move data between files.
Should be able to back up and recover the user’s files in case of damage.
Should be able to access the user’s files by using symbolic names.
What does file system architecture consist of?
Device driver
communicates directly with hardware device
Basic file system
Handles physical I/O
Basic I/O supervisor
Responsible for file I/O initiation and termination, device selection, I/O scheduling, buffer allocation
Logical I/O
enables users and applications to access records
provides record-oriented I/O capability
Access method
access files based on their structure and method of access
File management functions
Identify and locate a selected file.
Use a directory to describe the location of all files plus their attributes.
Enforce user access control (shared system).
Employ access method on the records.
Provide blocking for file I/O.
Block for output and unblock for input.
Manage secondary storage
Allocate files to available blocks.
Manage free storage of available blocks.
Scheduling of I/O requests
Criteria for choosing a file organization
Rapid access
ease of update
economy of storage
simple maintenance
reliability
There are a large number of file organizations. Most file organizations are related to one of the five fundamental file organizations
Pile
Sequential File
Indexed Sequential File
Indexed file
Direct or hashed file
How does the pile file organization work?
Data are collected in the order they arrive
Purpose is to accumulate a mass of data and save it
Records may have different structures or no structure
Data access is by exhaustive search
may be useful to store data prior to processing
How does the sequential file organization work?
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 field
uniquely identifies the record
records are stored in key sequence
New records are placed in a log file or transaction file
log file is periodically merged with the master file
useful in batch processing
Drawback of sequential file
must shift everything if you want to insert data (will make things slow for file)
so put new records in separate file before we merge it
Bad for lookup b/c we can’t just jump into the middle
Indexed Sequential File Organization
File is like a sequential file with key and data.
Index provides a lookup capability to quickly reach the vicinity of the desired record.
Greatly reduces the time required to access a single record, while still providing sequential processing.
Additions can be handled by an overflow file, which can be periodically merged with the main file.
Indexed File
Use multiple indexes for different key fields
Abandons sequential format with single key
records are accessed only by their index
Records can be variable length.
Exhaustive index has pointers to every record.
Partial index only has pointers to records having the field of interest.
Useful in applications such as an airline reservation system that need to access particular records quickly, but rarely need to process them sequentially.
What does a direct or hash file do?
When is it useful?
Turn key value into an address to support direct access of records in the file
Gives very rapid access to data
Useful if records are only accessed one at a time
How are indexes often implemented?
As B trees for low height
What information does the directory contain?
info about files
attributes
location
ownership
Itself, directory is a file owned by the OS
What structure is used for storing the file directory?
tree structure (at top is master, beneath are users)
In a multiuser system, files should be able to be shared between users, giving us two issues….
Access rights
Simultaneous access
What rights does the owner have to a file?
all access rights and may grant rights to others
Access rights may be given to different classes of users.
Typical classes are….
Specific user
a group of users
All
How do file sharing access rights work?
these rights constitute a hierarchy with higher level rights including the lower level ones
When does the OS or file management system must enforce discipline?
When access is granted to append or update a file to more than one user
How may the OS or file management system enforce discipline?
Lock the entire file when it is to be updated
Another approach is to lock individual records during update
Users work with a logical view of a file as a set of records.
How does the I/O view the file?
physical view; as a set of blocks
When we write to data, what happens?
What about if we read it?
blocking of records occur
unlocking is performed
Blocking considerations
The larger the block, the more records that are passed in a single I/O
For sequential access this reduces I/O’s, but may result in unnecessary data transfer for random access.
Typically blocks are of fixed length to simplify the I/O transfer.
List the blocking methods
Fixed
Variable-length spanned
Variable-length unspanned
Explain fixed blocking method
fixed length records
may cause internal fragmentation
Explain variable length spanned blocking method
variable length records which may span blocks
permits unlimited record size
may require multiple I/Os
Explain variable-length unspanned blocking method
variable-length records which do not span blocks
may cause internal fragmentation
A file consists of a collection of blocks on what device?
secondary storage device
What manages the blocks?
OS/file management system
What are two management issues when it comes to managing blocks on the secondary storage device?
Allocating blocks to files
Maintaining a list of free blocks
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.
What does preallocation require?
max file size be declared and allocated when the file is created (leads to overrequesting)
What does dynamic allocation allow?
ports of space to be given to the file so it can grow dynamically (but keeping track of seaprate pieces is hard)
Allocation Portion size methods
Large, variable-length contiguous portion
good performance
may cause fragmenetation
simple allocation table with pointer to beginning and length
Small fixed-sized blocks
good flexbility
requires more complicated allocation table to keep track of non-contiguous blocks
Three methods of file allocation
Contiguous allocation
a single contiguous set of blocks is allocated to a file at the time of file creation. Thus, this is a preallocation method of a variable-size portion. May require periodic compaction due to fragmentation. Good for sequential file access.
Chained allocation
allocate individual blocks. Each block contains a pointer to the next block.
Indexed allocation
an index specifies the location of each block.
What does the disk allocation table do?
What are its techniques?
keeps track of available space (need to know to perform allocations)
bit tables
each bit represents a block
chained free portions
free portions are chained together
indexing
index keeps track of every free portion as if it was a file
Free block list
blocks are numbered and list of free block numbers is maintained