0% found this document useful (0 votes)
16 views

Operating Systems: I/O & File Management

The document discusses file management in operating systems. It covers the objectives of file management systems, typical file operations, file attributes, file organization methods including contiguous, linked and indexed allocation, and performance considerations like allocation methods. The main techniques for file organization and access explained are hierarchical file structures using directories, file attributes stored in inodes, and indexed allocation using inodes containing direct and indirect block addresses.

Uploaded by

feleciawalters
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Operating Systems: I/O & File Management

The document discusses file management in operating systems. It covers the objectives of file management systems, typical file operations, file attributes, file organization methods including contiguous, linked and indexed allocation, and performance considerations like allocation methods. The main techniques for file organization and access explained are hierarchical file structures using directories, file attributes stored in inodes, and indexed allocation using inodes containing direct and indirect block addresses.

Uploaded by

feleciawalters
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Operating Systems

I/O & File Management


Lecture 10: File Management
Objectives

▪ At the end, you should be able to:


– explain the principal techniques for file organization and access
Files

▪ Files are the central element to most applications


▪ The File System is one of the most important part of the OS to a user
▪ Desirable properties of files:
– Long-term existence
– Sharable between processes
– Structure
Typical Operations

▪ File systems also provide functions which can be performed on files,


typically:
– Create
– Delete
– Open
– Close
– Read
– Write
File Attributes
– Name: symbolic file-name, only information in human-readable form
– Identifier: Unique tag that identifies file within filesystem; non-human readable
name
– 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 & usage
monitoring

▪ Information about files are kept in the directory structure, maintained


on disk
In Linux ls -l will show you
the properties of a file
File Attributes

▪ Also in Linux the stat command can be used to display detailed


information relating to a file or file system on a Linux system
▪ In the example below you can see the default output from the
command
Four terms are in common use when
discussing files

▪ Fields ▪ File
– Basic element of data – Have file names
– Contains a single value – Is a collection of similar records
– Characterized by its length and – Treated as a single entity
data type – May implement access control
mechanisms
▪ Records
– Collection of related fields ▪ Database
– Treated as a unit – Collection of related data
– Relationships exist among
elements
– Consists of one or more files
File Management Systems

▪ File management system consists of system utility programs that run


as privileged applications
▪ Concerned with secondary storage
▪ Provides services to users and applications in the use of files
– The way a user or application accesses files

▪ Programmer does not need to develop file management software


Objectives for a File Management System

▪ Meet the data management needs 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 lost or destroyed data
▪ Provide a standardized set of I/O interface routines to user
processes
▪ Provide I/O support for multiple users (if needed)
Requirements for a
general purpose system

1. Each user should be able to create, delete, read, write and modify
files
2. Each user may have controlled access to other users’ files
3. Each user may control what type of accesses are allowed to the
users’ files
4. Each user should be able to restructure the user’s files in a form
appropriate to the problem
Requirements cont.

5. Each user should be able to move data between files


6. Each user should be able to back up and recover the user’s files in
case of damage
7. Each user should be able to access the user’s files by using symbolic
names
Typical File System Software
Architecture
Device Drivers

▪ Lowest level
▪ Communicates directly with
peripheral devices
▪ Responsible for starting I/O
operations on a device
▪ Processes the completion of an
I/O request
▪ Device drivers are usually
considered to be part of the OS
Basic File System

▪ AKA. Physical I/O


▪ Primary interface with the
environment outside the
computer system
▪ Deals with exchanging blocks
of data
▪ Concerned with the placement
of blocks
▪ Concerned with buffering
blocks in main memory
Basic I/O Supervisor

▪ Responsible for all file I/O


initiation and termination.
▪ Control structures deal with
• Device I/O,
• Scheduling,
• File status.

• Selects and schedules I/O with


the device
• The basic I/O supervisor is part
of the operating system
Logical I/O

▪ Enables users and applications


to access records
▪ Provides general-purpose
record I/O capability
▪ Maintains basic data about file
Access Method

▪ Closest to the user


▪ Reflect different file structures
▪ Provides a standard interface
between applications and the
file systems and devices that
hold the data
▪ Access method varies
depending on the ways to
access and process data for the
device.
Elements of
File Management
File Organization

▪ Refers to the logical structuring of the records as determined by the


way in which they are accessed.
▪ Many types exist, but usually variations of:
– Pile
– Sequential file
Files
– Indexed sequential file
– Indexed file
– Direct, or hashed, file Sequentia
Random
l

Indexed
Sequentia Direct or
Pile Sequentia Indexed
l Hashed
l
The Pile

▪ Data are collected in the order they arrive


– No structure

▪ Purpose is to accumulate a mass of data and save it


▪ Records may have different fields
▪ Record access is by exhaustive search
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
▪ Key field
– Uniquely identifies the record
– Records are stored in key sequence
Indexed Sequential File

▪ Maintains the key characteristic of the sequential file:


• records are organized in sequence based on a key field.

Two features are added:


• an index to the file to support random access,
• and an overflow file.
Indexed File

▪ Uses multiple indexes for different key fields


– May contain an exhaustive index that contains one entry for every record in the
main file
– May contain a partial index

▪ When a new record is added to the main file, all of the index files
must be updated.
Hashed or Direct File

▪ Access directly any block of a known address.


▪ The Direct or Hashed File
– Directly access a block at a known address
– Key field required for each record
Performance
Allocation Methods

▪ An allocation method refers to how disk blocks are allocated for files:
– Contiguous allocation
– Linked allocation
– Indexed allocation
Allocation Methods
Contiguous Allocation

▪ Each file occupies a set of contiguous


blocks on the disk

▪ Simple – only starting location (block #)


and length (number of blocks) are
required

▪ Random access

▪ Wasteful of space (dynamic storage-


allocation problem)

▪ Files cannot grow


Allocation Methods
Linked Allocation

▪ Each file is a linked list of disk


blocks: blocks may be
scattered anywhere on the
disk.

– Simple – need only starting


address
– Free-space management system –
no waste of space
– No random access
Allocation Methods
Indexed Allocation

▪ Brings all pointers together


into the index block.
– Need index table
– Random access

▪ Dynamic access without


external fragmentation, but
have overhead of index block.
Allocation Methods
Indexed Allocation: Inode

▪ A file system contains ‘blocks’


which hold data called inodes.

▪ A inode describes a single file in


a file system

A Typical Inode
Allocation Methods
Indexed Allocation: Inode Example

Question Solution

▪ A file system has: ▪ Number of block address per block =


– Inode contains 12 direct block 1024/4 = 256
addresses ▪ Direct Block = 12
– Inode contains 1 indirect block
▪ Indirect Block = 256
address
– Inode contains 1 double-indirect ▪ Double-Indirect Block = 256 * 256
block address

▪ If block address are 4bytes and ▪ Max file


blocks are 1024bytes, what is the – = (12+256+(256*256))*1024
maximum file size? – = 67383296 bytes (66MB)
Reading Resources

▪ Operation Systems: Internals and Design Principles by William


Stallings
– Chapters 12

▪ Operating System Concepts by Silberschatz, Galvin, & Gagne


– Chapters 11

▪ Understanding Operating Systems by McHoes & Flynn


– Chapter 8

You might also like