File access methods.54

myrajendra 25,890 views 26 slides Mar 22, 2013
Slide 1
Slide 1 of 26
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26

About This Presentation

No description available for this slideshow.


Slide Content

1
File Concept, File Management, File

9CM 402.54 2
Recap
In the last class, you have learnt:
•File and File operations

•HOME PREVIOUS TOPIC NEXT
•PREVIOUS QUESTION PAPERS FOR
OS
•CPP TUTORIALS
3

9CM 402.54 4
Objective(s)
On completion of this period, you would be able to:

•Understand the different file access methods
• Introduction to directory

9CM 402.54 5
Introduction
•Files store information
•This information must be accessed and read into
computer memory for use
•There are different access methods
•Some systems support only one access method
•Other systems support different access methods

9CM 402.54 6
Types of Access Methods
• Sequential Access
• Direct Access
• Other Access Methods

9CM 402.54 7
Sequential Access
•Simplest access method
•Information processed in order
•Most common
•Used by editors and compilers
•Based on a tape model of a file
•Works well on sequential access devices and
random access devices

9CM 402.54 8
Sequential Access
beginning
current position
end
read or write
rewind
Fig : Sequential Access File

9CM 402.54 9
Most Common Operations on Files
•Read
•Write

9CM 402.54 10
File Pointer
• Whenever a file is opened for read or write
operation a file pointer is maintained to keep
track of the current position in the file

9CM 402.54 11
Read operation
• Reads the next portion of the file
• Automatically advances file pointer

9CM 402.54 12
Write operation
•Appends data to the end of the file
•Advances pointer to the new end of file

9CM 402.54 13
Reset
•Reset to beginning

9CM 402.54 14
Skip
•Skip n records forwards or backwards
( supported by few systems )

9CM 402.54 15
Applications for sequential access
•Payroll of employees
•Student data processing

9CM 402.54 16
Direct Access
•Also known as Relative Access
•Fixed length logical records
•No particular order for read and write
•Based on disk model of a file
•File viewed as a numbered sequence of blocks or
records
•Arbitrary block read or written

9CM 402.54 17
Direct Access
•Useful for immediate access to large volumes of
data
•Most suitable for database applications
•Easy to read, write and delete a record

9CM 402.54 18
•Address of arbitrary record N
Let length of logical record = L
Address of record N = L*(N-1)
Direct Access

9CM 402.54 19
Simulate Sequential Access
•Easy to simulate sequential access on direct
access file
•Keep a variable cp i.e. Current position

9CM 402.54 20
Sequential AccessImplementation for
direct access
reset cp := 0
read next read cp
cp := cp + 1
write next write cp
cp := cp + 1
Fig : Simulation of sequential access on a direct access file
Simulate Sequential Access

9CM 402.54 21
Applications for Direct access
•Airline reservation system
•Customer account processing in a bank

9CM 402.54 22
Other Access Methods
•Built on top of direct access method
•Require the construction of an index for the file
•Index is a small table stored in memory
•The index contains pointers to various blocks

9CM 402.54 23
To find an entry in the file…
•Search the index
•Use the pointer to access the file directly
for the desired entry

9CM 402.54 24
To find an entry in the file
Adams
Arthur
Asher
.
.
.
Smith
Smith, John SSN
Age
last name
logical record
number
index file
relative file

9CM 402.54 25
Primary index and Secondary index
•With large files index file itself too large to
be in memory
•Solution is create index for the index file
•Primary index points to secondary index
•Secondary index points to actual data

Other subject materials
•Web designing
•Micro processors
•C++ tutorials
•java
home
Tags