Chapter 3 part 1

19
Chapter 3: File Management Part 1

description

 

Transcript of Chapter 3 part 1

Page 1: Chapter 3 part 1

Chapter 3: File ManagementPart 1

Page 2: Chapter 3 part 1

Learning outcome:By the end of this lecture, students will be

able to:1)Identify basic function of file system2)Describe file organization techniques3)Describe types of file structure4)Describe various methods of file allocation

Page 3: Chapter 3 part 1

File Management : IntroductionFile management system can be define as a system

that an operating system uses to keep track of different files.

Unlike the CPU and memory management aspects of the operating system which aim mainly towards an optimum use of the CPU, file management aims to provide a convenient programming environment for the users of the system.

There are several functions that must be performed by an efficient file system: include storing of files in an orderly fashion accessing the stored files appending the stored files and protecting the

files from loss of data

Page 4: Chapter 3 part 1

File Structure

Page 5: Chapter 3 part 1

File organization techniques Concerned with how records are arranged &

characteristics of medium used to store it. On magnetic disks, files can be organized as:

1) Sequential2) Direct3) Indexed sequential

Page 6: Chapter 3 part 1

Characteristics Considered When Selecting File OrganizationVolatility of data—frequency with which

additions & deletions made.

Activity of file—% records processed during a given run.

Size of file.

Response time—amount of time user is willing to wait before requested operation is completed.

Page 7: Chapter 3 part 1

1) SequentialEasiest to implement because records are

stored & retrieved serially, one after other. To speed process some optimization features

may be built into system. E.g., select a key field from record & then sort

records by that field before storing them. Aids search process.Complicates maintenance algorithms because

original order must be preserved every time records added or deleted.

Page 8: Chapter 3 part 1

2) DirectUses direct access files which can be

implemented only on direct access storage devices. Give users flexibility of accessing any record in any

order without having to begin search from beginning of file.

Records are identified by their relative addresses (their addresses relative to beginning of file). Logical addresses computed when records are

stored & again when records are retrieved.Use hashing algorithms

Page 9: Chapter 3 part 1

Advantages:1)Fast access to records.2)Can be updated more quickly than sequential

files because records quickly rewritten to original addresses after modifications

Disadvantage:1)Several records with unique keys may

generate same logical address (collision)

Page 10: Chapter 3 part 1

3) Indexed sequentialCombines best of sequential & direct access. Created & maintained through Indexed Sequential

Access Method (ISAM) software package.Doesn’t create collisions because it doesn’t use result

of hashing algorithm to generate a record’s address. Uses info to generate index file through which records retrieved.

Divides ordered sequential file into blocks of equal size. Size determined by File Manager to take advantage of physical

storage devices & to optimize retrieval strategies. Each entry in index file contains highest record key &

physical location of data block where this record, & records with smaller keys, are stored.

Page 11: Chapter 3 part 1

Methods of file allocationFile manager works with files

As whole unitsAs logical units or records

Within fileRecords must have same formatRecord length may vary

Records subdivided into fieldsApplication programs manage record structureThree methods:1)Contiguous file allocation2) Linked list non-contiguous (using blocks)3)Linked list non-contiguous (using index)

Page 12: Chapter 3 part 1
Page 13: Chapter 3 part 1

1) Contiguous file allocationRecords stored one after another

Advantages Any record found once starting address, size known Easy direct access

Disadvantages Difficult file expansion, fragmentation

Page 14: Chapter 3 part 1

2) Linked list non-contiguous (using blocks)Files use any available disk storage spaceFile records stored in contiguous manner

If enough empty spaceRemaining file records and additions

Stored in other disk sections (extents)Extents

Linked together with pointers Physical size determined by operating system Usually 256 bytes

Page 15: Chapter 3 part 1

File extents linked in two waysStorage level

Each extent points to next one in sequence Directory entry Filename, storage location of first extent, location of

last extent, total number of extents (not counting first)

Directory level Each extent listed with physical address, size,

pointer to next extent Null pointer indicates last one

AdvantageEliminates external storage fragmentationEliminates need for compaction

DisadvantageNo direct access support

Cannot determine specific record’s exact location

Page 16: Chapter 3 part 1
Page 17: Chapter 3 part 1
Page 18: Chapter 3 part 1

3) Linked list non-contiguous allocation (using index)

Allows direct record accessBrings pointers together

Links every extent file into index block

Every file has own index block Disk sector addresses for fileLists entry in order sectors linked

Supports sequential and direct accessDoes not necessarily improve storage space

useLarger files experience several index levels

Page 19: Chapter 3 part 1