Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

File access methods.54


Published on

File access methods.54

  1. 1. File Concept, File Management, File 1
  2. 2. RecapIn the last class, you have learnt:• File and File operations 9CM 402.54 2
  4. 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 4
  5. 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 5
  6. 6. Types of Access Methods• Sequential Access• Direct Access• Other Access Methods 9CM 402.54 6
  7. 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 7
  8. 8. Sequential Access current positionbeginning end rewind read or write Fig : Sequential Access File 9CM 402.54 8
  9. 9. Most Common Operations on Files• Read• Write 9CM 402.54 9
  10. 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 10
  11. 11. Read operation• Reads the next portion of the file• Automatically advances file pointer 9CM 402.54 11
  12. 12. Write operation• Appends data to the end of the file• Advances pointer to the new end of file 9CM 402.54 12
  13. 13. Reset• Reset to beginning 9CM 402.54 13
  14. 14. Skip• Skip n records forwards or backwards ( supported by few systems ) 9CM 402.54 14
  15. 15. Applications for sequential access• Payroll of employees• Student data processing 9CM 402.54 15
  16. 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 16
  17. 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 17
  18. 18. Direct Access•Address of arbitrary record N Let length of logical record = L Address of record N = L*(N-1) 9CM 402.54 18
  19. 19. Simulate Sequential Access• Easy to simulate sequential access on direct access file• Keep a variable cp i.e. Current position 9CM 402.54 19
  20. 20. Simulate Sequential Access Sequential Access Implementation for direct access reset cp := 0 read next read cp cp := cp + 1 write next write cp cp := cp + 1Fig : Simulation of sequential access on a direct access file 9CM 402.54 20
  21. 21. Applications for Direct access• Airline reservation system• Customer account processing in a bank 9CM 402.54 21
  22. 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 22
  23. 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 23
  24. 24. To find an entry in the file logical recordlast name number Adams Arthur Asher Smith, John SSN Age . . . Smith relative file index file 9CM 402.54 24
  25. 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 9CM 402.54 25
  26. 26. Other subject materials• Web designing• Micro processors• C++ tutorials• javahome