DISK SCHEDULING PROBLEMS REFER NOTES AND ASSIGNMENT
Disk Management
n Disk Formatting
n Boot Block
n Bad Blocks
Swap-Space Management
File Concept
OS provides a uniform logical view (file) of various information storage devices by abstracting from
the physical properties of storage devices
A file is a collection of related information that is recorded on secondary storage
Types of file
Data
Numeric, alphabetic, alphanumeric, or binary
Program
Source, object, executable
File Structure
None - sequence of words, bytes such as text file
Simple record structure
Lines
Fixed length record
Variable length record
Complex structures
Formatted document (e.g. html)
Relocatable load file (e.g. object file)
Can simulate last two with first method by inserting appropriate control characters
File Attributes
� A file has several attributes: (vary from one OS to another)
Name – only information kept in human-readable form
Identifier – unique tag (number) identifies file within file system
Type – needed for systems that support different types
Location – pointer to file location on device
Size – current file size
� Protection – controls who can do reading, writing, executing
� Time, date, and user identification – data for protection, security,
and usage monitoring
Information about files are kept in the directory structure, which is maintained on the disk
File Operations
� OS provides various system calls for file operations
� For example:
Create
Write
Read
Reposition within file – file seek
Delete
Truncate
Open(Fi) – search the directory structure on disk for entry Fi, and
move the content of entry to memory
Close (Fi) – move the content of entry Fi in memory to directory
File Types – Name, Extension
Access Methods
Sequential Access: information in the file is processed in order
o read next-reads the next portion of the file and�automatically�advances�a�file�pointer
o write next – appends to the end of the file and advances to the end of the newly written
material�(the�new�end�of�file).�
o reset- file can be reset to the beginning, and on some systems, a program may be able to
skip forward or backward n records
read next
write next
reset
skip forward or backward n records
Direct Access: allow arbitrary blocks to be read or written
read n (n = relative block number)
write n
position to n
read next
write next
rewrite n
Simulation of Sequential Access on a Direct-access File
Example of Index and Relative Files
Directory Structure
A Typical File-system Organization
Every partition has a file system, which consists of directory and files
A collection of nodes containing information about all files
Both the directory structure and the files reside on disk
Backups of these two structures are kept on tapes
Information in a Directory
Name
Type
Address
Current length
Maximum length
Date last accessed
Date last updated
Owner ID
Protection information
Operations Performed on a Directory
Search for a file
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system
How to Organize a Directory?
Issues
Efficiency – locating a file quickly
Naming – convenient to users
Two users can have same name for different files
The same file can have several different names
Grouping – logical grouping of files by properties (e.g. all Java programs,�all�games,�…)
Schemes for defining the logical structure of a directory:
Single level directory
Two level directory
Tree structured directory
Acyclic graph directory
General graph directory
Single-Level Directory
A single directory for all users; easy to support and understand
Problems
Naming problem: all files must have unique names
Grouping problem
Two-Level Directory
As, a single-level directory often leads to confusion of file names among different users.
The standard solution is to create a separate directory for each user.
In the two-level directory structure, each user has own user file directory (UFD).
The U F D s have similar structures, but each lists only the files of a single user. When a
user job starts or a user logs in, the system’s master file directory ( M F D ) is
searched.
When a user refers to a particular file, only his own U F D is searched.
Thus, different users may have files with the same name, as long as all the file names
within each U F D are unique.
To create a file for a user, the operating system searches only that user’s U F D to
ascertain whether another file of that name exists.
To delete a file, the operating system confines its search to the local U F D ; thus, it cannot
accidentally delete another user’s file that has the same name.
� A user name and a file name define a path name
� Advantages and disadvantages
Can have the same file name for different user
Efficient searching
No grouping capability
Tree-Structured Directories
A tree is the most common directory structure.
The tree has a root directory, and every file in the system has a unique path name. A directory (or
subdirectory) contains a set of files or subdirectories.
All directories have the same internal format. One bit in each directory entry defines the entry as a
file (0) or as a subdirectory (1).
Special system calls are used to create and delete directories.
The current directory should contain most of the files that are of current interest to the process.
When reference is made to a file, the current directory is searched. If a file is needed that is not in the
current directory, then the user usually must either specify a path name or change the current directory to
be the directory holding that file.
To change directories, a system call is provided that takes a directory name as a parameter and uses
it to redefine the current directory.
Path names can be of two types: absolute and relative.
-An absolute path name begins at the root and follows a path down to the specified file, giving the directory
names on the path.
A relative path name defines a path from the current directory
Advantages
Efficient searching
Grouping Capability
DisAdvantages
Subdirectories cannot be shared by multiple user
Acyclic-Graph Directories
Have shared subdirectories and files using acyclic graph
With a shared file only one actual file exists, so any changes made by one person are immediately
visible to the other
Deletion:
o The deletion of a link does not need to affect the original file; only the link is removed.
o Another approach to deletion is to preserve the file until all references to it are deleted.
o Another approach keep a count of the number of references.
o When count=0, file is deleted.
File System Mounting
Just as a file must be opened before it is used, a file system must be mounted before it can be
accessed
Procedure
The operating system is given the name of the device, and the location within the file
structure at which to attach the file system (or mount point)
Typically, a mount point is an empty directory
The operating system verifies that the device contains a valid file system by asking
the device driver to read the directory
Finally, the operating system notes in its directory structure that a file system is
mounted at the specified mount point; This scheme enables the operating system to traverse its
directory structure, switching among file systems as appropriate
Example of File System Mounting
Existing Unmounted Partition Mount Point
File Sharing
Sharing of files on multi-user systems is desirable
Sharing may be done through a protection scheme
On distributed systems, files may be shared across a network
Network File System (NFS) is a common distributed file-sharing method
File Sharing – Multiple Users
User IDs identify users, allowing permissions and protections to be per-user
Group IDs allow users to be in groups, permitting group access rights
File Sharing – Remote File Systems
Uses networking to allow file system access between systems
Manually via programs like FTP
Automatically, seamlessly using distributed file systems
Semi automatically via the world wide web
� Client-server model allows clients to mount remote file systems from servers
Server can serve multiple clients
Client and user-on-client identification is insecure or complicated
NFS is standard UNIX client-server file sharing protocol
CIFS is standard Windows protocol
Standard operating system file calls are translated into remote calls
Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS, Active
Directory implement unified access to information needed for remote computing
File Sharing – Failure Modes
Remote file systems add new failure modes, due to network failure, server failure
Recovery from failure can involve state information about status of each remote request
Stateless protocols such as NFS include all information in each request, allowing easy recovery but
less security
File Protection
File owner/creator should be able to control:
what can be done
by whom
Types of access
Read
Write
Execute
Append
Delete
List
Access Control List
Various users may need different types of access to a file or directory
The most general scheme is to associate with each file and directory an access-control list (ACL)
specifying the user name and the types of access allowed for each user
Advantages
Enable complex access methodology
Disadvantages
Constructing such a list may be a tedious and unrewarding task, especially if we do
not know in advance the list of users in the system
The directory entry, previously of fixed size, now needs to be of variable size,
resulting in more complicated space management
Access Lists and Groups (UNIX)
Mode of access: read, write, execute
Three classes of users
RWX
a) owner access 7 1 1 1
RWX
b) group access 6 1 1 0
RWX
c) public access 1 0 0 1
Ask manager to create a group (unique name), say G, and add some users to the group
For a particular file (say game) or subdirectory, define an appropriate access
owner group public
chmod 761 game
Attach a group to a file using
chgrp G game