22
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 File store information When it is used it is accessed read into memory Some systems provide only one access method IBM support many access

Embed Size (px)

DESCRIPTION

Sequential-access File  Simplest access method  Information accessed- one record after the other  Common method – ex: editors & compilers  Bulk of operations in file is read & write  Read – reads the next portion of the file & advances file pointer  Write – appends the end of the file & advances to the newly written material  Beginning – reset  Forward & backward n records – skip  Sequential access is based on the tape model of a file

Citation preview

Page 1: 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

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

Page 2: 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

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

Page 3: 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

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

Page 4: 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

Sequential-access File

Page 5: 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

Simulation of Sequential Access on a Direct-access File

Page 6: 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

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

Page 7: 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

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

Page 8: 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

Example of Index and Relative Files

Page 9: 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

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

Page 10: 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

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

Page 11: 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

A Typical File-system Organization

Page 12: 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

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

Page 13: 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

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, …)

Page 14: 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

Single-Level DirectoryA single directory for all users

Naming problem

Grouping problem

Page 15: 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

Two-Level DirectorySeparate directory for each user

Path name Can have the same file name for different user Efficient searching No grouping capability

Page 16: 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

Tree-Structured Directories

Page 17: 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

Tree-Structured Directories (Cont)Efficient searching

Grouping Capability

Current directory (working directory)cd /spell/mail/progtype list

Page 18: 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

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

mail

prog copy prt exp count

Deleting “mail” deleting the entire subtree rooted by “mail”

Page 19: 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

Acyclic-Graph DirectoriesHave shared subdirectories and files

Page 20: 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

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

Page 21: 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

General Graph Directory

Page 22: 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

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