Access Methods File store information When it is used it is accessed & read into memory Some systems provide only one access method IBM support many access methods Choosing right one for a particular application
Jan 18, 2018
Access Methods File store information
When it is used it is accessed & read into memory
Some systems provide only one access method
IBM support many access methods
Choosing right one for a particular application
Access Methods Sequential Access
read nextwrite next resetno read after last write
(rewrite) Direct Access
read nwrite nposition to n
read nextwrite next
rewrite nn = relative block number
Sequential-access FileSimplest access method
Information accessed- one record after the otherCommon method – ex: editors & compilers
Bulk of operations in file is read & writeRead – reads the next portion of the file & advances file pointerWrite – appends the end of the file & advances to the newly written material
Beginning – resetForward & backward n records – skip
Sequential access is based on the tape model of a file
Sequential-access File
Simulation of Sequential Access on a Direct-access File
Direct Access (relative access)file – fixed length, logical records (allow programs to read & write
rapidly) , no particular orderRandom access to any file blockBased on disk model of a fileFile is viewed as a numbered sequence of blocks / recordsNo restrictions – read 24, read 54, write 5Block number provided by user to OS is normally a relative block
numberIt is an index relative to index of a fileRelative blocks – 0,1,… / 1,………..Use – allows OS to decide where the file should be placed &helps
users from accessing file part that is not a part of itLogical record length – L request for record – N turns to I/O request for L bytes starting from location L*(N-1) within the fileLogical records are of fixed size – easy to read, write & delete a record
Other access methodsThey can built on the top of the direct access methodInvolve the construction of index for a fileContains pointers for various blocksFind a record in a file – search the index – use the pointer to access the
file directly – find the desired recordEx: retail price fileLarge files – index file will be large to be to kept in memorySolution – create an index for the indexed filePrimary index file contain pointers to secondary index file which would point actual data itemEx: IBM’s indexed sequential access method (ISAM) uses small master
index for secondary indexFind a item: binary search in master index for finding the block number
in secondary index – block is read – again binary search to find the block containing the desired record – block is searched
sequentiallyAny records can be accessed by this two direct access reads
Example of Index and Relative Files
Directory StructureA collection of nodes containing information about all files
F 1 F 2F 3
F 4
F n
Directory
Files
Both the directory structure and the files reside on diskBackups of these two structures are kept on tapes
The file systems of computer can be extensiveStore – millions of files (TB), manage – organizeOrganization – 2 parts:
Disk split into 1/more partitions – minidisksPartition – low level structure – files & directories
residePartition contains information about files in itInformation is kept in device directory / volume table
of contentsDevice dir – records name , location, size, typeDirectory – symbol table – translates file name into
directoriesInsert, delete, search, list all entries
A Typical File-system Organization
Operations Performed on DirectorySearch for a file – dir struct – entry for a fileCreate a file – new file created & added to
dirDelete a file –no longer needed remove
from directoryList a directory- list all the filesRename a file – changing the nameTraverse the file system – checking the
entire directory
Organize the Directory (Logically) to Obtain
Efficiency – locating a file quicklyNaming – 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, …)
Single-Level DirectoryA single directory for all users
Naming problem
Grouping problem
Two-Level DirectorySeparate directory for each user
Path name Can have the same file name for different user Efficient searching No grouping capability
Tree-Structured Directories
Tree-Structured Directories (Cont)Efficient searching
Grouping Capability
Current directory (working directory)cd /spell/mail/progtype list
Tree-Structured Directories (Cont)
Absolute or relative path nameCreating a new file is done in current directoryDelete a file
rm <file-name>Creating a new subdirectory is done in current
directorymkdir <dir-name>
Example: if in current directory /mailmkdir count
prog copy prt exp count
Deleting “mail” deleting the entire subtree rooted by “mail”
Acyclic-Graph DirectoriesHave shared subdirectories and files
Acyclic-Graph Directories (Cont.)Two different names (aliasing)
If dict deletes list dangling pointerSolutions:Backpointers, so we can delete all pointers
Variable size records a problemBackpointers using a daisy chain organizationEntry-hold-count solution
New directory entry typeLink – another name (pointer) to an existing fileResolve the link – follow pointer to locate the file
General Graph Directory
General Graph Directory (Cont.)How do we guarantee no cycles?
Allow only links to file not subdirectoriesGarbage collectionEvery time a new link is added use a cycle
detectionalgorithm to determine whether it is OK