Chapter 12: File Management

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 45

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

46 Terms

1

List the desirable properties of files

  1. Long term existence

    1. kept on secondary storage

  2. Sharable between processes

  3. Structure

    1. internal structure of file so it can be organized to be suitable for certain applications

New cards
2

File structure: What is a field?

  • Basic element of data

  • contains a single value

  • characterized by its length and data type

  • can be fixed length or variable length

New cards
3

File structure: What is a record?

  • collection of related fields

  • treated as a unit

  • can be variable length if some fields are variable length or if number of fields vary

New cards
4

File structure: What is a file?

  • a collection of similar records

  • treated as a single entity

  • have unique file names

  • may restrict access

New cards
5

File structure: What is a database?

  • collection of related data (one or more files)

  • relationships exist among elements

  • managed by separate DBMS

New cards
6

Do UNIX bytes have internal structure?

No, they’re just streams of bytes

New cards
7

What is a file management system?

  • set of system software providing file services to users and applications

  • programmer does not need to develop file management software for each application

New cards
8

Objectives for a file management system

  1. Meet the data management needs and requirements of the user

  2. Guarantee that the data in the file are valid

  3. Optimize performance

  4. Provide I/O support for a variety of storage device types

  5. minimize or eliminate the potential for lost of destroyed data

  6. provide a standardized set of I/O interface routines

  7. Provide I/O support for multiple users

New cards
9

User requirements for file management system

  1. Should be able to create, delete, read and change files

  2. May have controlled access to other users’ files.

  3. May control what type of accesses are allowed to the user’s files.

  4. Should be able to restructure the user’s files in a form appropriate to the problem.

  5. Should be able to move data between files.

  6. Should be able to back up and recover the user’s files in case of damage.

  7. Should be able to access the user’s files by using symbolic names.

New cards
10

What does file system architecture consist of?

  1. Device driver

    1. communicates directly with hardware device

  2. Basic file system

    1. Handles physical I/O

  3. Basic I/O supervisor

    1. Responsible for file I/O initiation and termination, device selection, I/O scheduling, buffer allocation

  4. Logical I/O

    1. enables users and applications to access records

    2. provides record-oriented I/O capability

  5. Access method

    1. access files based on their structure and method of access

<ol><li><p>Device driver </p><ol><li><p>communicates directly with hardware device </p><p></p></li></ol></li><li><p>Basic file system </p><ol><li><p>Handles physical I/O </p><p></p></li></ol></li><li><p>Basic I/O supervisor</p><ol><li><p>Responsible for file I/O initiation and termination, device selection, I/O scheduling, buffer allocation </p></li></ol><p></p></li><li><p>Logical I/O </p><ol><li><p>enables users and applications to access records</p></li><li><p>provides record-oriented I/O capability </p><p></p></li></ol></li><li><p>Access method</p><ol><li><p>access files based on their structure and method of access </p></li></ol></li></ol>
New cards
11

File management functions

  1. Identify and locate a selected file.

    1. Use a directory to describe the location of all files plus their attributes.

  2. Enforce user access control (shared system).

  3. Employ access method on the records.

  4. Provide blocking for file I/O.

    1. Block for output and unblock for input.

  5. Manage secondary storage

    1. Allocate files to available blocks.

    2. Manage free storage of available blocks.

    3. Scheduling of I/O requests

<ol><li><p><span>Identify and locate a selected file.</span></p><ol><li><p><span>Use a directory to describe the location of all files plus their attributes.</span></p><p></p></li></ol></li><li><p><span>Enforce user access control (shared system).</span></p><p></p></li><li><p><span>Employ access method on the records.</span></p><p></p></li><li><p><span>Provide blocking for file I/O. </span></p><ol><li><p><span>Block for output and unblock for input.</span></p><p></p></li></ol></li><li><p><span>Manage secondary storage</span></p><ol><li><p><span>Allocate files to available blocks.</span></p></li><li><p><span>Manage free storage of available blocks.</span></p></li><li><p><span>Scheduling of I/O requests</span></p></li></ol></li></ol>
New cards
12

Criteria for choosing a file organization

  1. Rapid access

  2. ease of update

  3. economy of storage

  4. simple maintenance

  5. reliability

New cards
13

There are a large number of file organizations. Most file organizations are related to one of the five fundamental file organizations

  1. Pile

  2. Sequential File

  3. Indexed Sequential File

  4. Indexed file

  5. Direct or hashed file

New cards
14

How does the pile file organization work?

  1. Data are collected in the order they arrive

  2. Purpose is to accumulate a mass of data and save it

  3. Records may have different structures or no structure

  4. Data access is by exhaustive search

  5. may be useful to store data prior to processing

<ol><li><p>Data are collected in the order they arrive</p><p></p></li><li><p>Purpose is to accumulate a mass of data and save it </p><p></p></li><li><p>Records may have different structures or no structure</p><p></p></li><li><p>Data access is by exhaustive search</p><p></p></li><li><p>may be useful to store data prior to processing</p></li></ol>
New cards
15

How does the sequential file organization work?

  1. Fixed format used for records

  2. records are the same length

  3. all fields the same (order and length)

  4. field names and lengths are attributes of the file

  5. one field is the key field

    1. uniquely identifies the record

    2. records are stored in key sequence

  6. New records are placed in a log file or transaction file

  7. log file is periodically merged with the master file

  8. useful in batch processing

<ol><li><p>Fixed format used for records </p><p></p></li><li><p>records are the same length </p><p></p></li><li><p>all fields the same (order and length) </p><p></p></li><li><p>field names and lengths are attributes of the file</p><p></p></li><li><p>one field is the key field</p><ol><li><p>uniquely identifies the record</p></li><li><p>records are stored in key sequence </p><p></p></li></ol></li><li><p>New records are placed in a log file or transaction file </p><p></p></li><li><p>log file is periodically merged with the master file </p><p></p></li><li><p>useful in batch processing </p></li></ol>
New cards
16

Drawback of sequential file

  • must shift everything if you want to insert data (will make things slow for file)

    • so put new records in separate file before we merge it

  • Bad for lookup b/c we can’t just jump into the middle

New cards
17

Indexed Sequential File Organization

  • File is like a sequential file with key and data.

  • Index provides a lookup capability to quickly reach the vicinity of the desired record.

  • Greatly reduces the time required to access a single record, while still providing sequential processing.

  • Additions can be handled by an overflow file, which can be periodically merged with the main file.

<ul><li><p>File is like a sequential file with key and data.</p><p></p></li><li><p>Index provides a lookup capability to quickly reach the vicinity of the desired record.</p><p></p></li><li><p>Greatly reduces the time required to access a single record, while still providing sequential processing.</p><p></p></li><li><p>Additions can be handled by an overflow file, which can be periodically merged with the main file.</p><p></p></li></ul>
New cards
18

Indexed File

  1. Use multiple indexes for different key fields

  2. Abandons sequential format with single key

  3. records are accessed only by their index

  4. Records can be variable length.

  5. Exhaustive index has pointers to every record.

  6. Partial index only has pointers to records having the field of interest.

  7. Useful in applications such as an airline reservation system that need to access particular records quickly, but rarely need to process them sequentially.

<ol><li><p>Use multiple indexes for different key fields </p><p></p></li><li><p>Abandons sequential format with single key</p><p> </p></li><li><p>records are accessed only by their index </p><p></p></li><li><p>Records can be variable length.</p><p></p></li><li><p>Exhaustive index has pointers to every record.</p><p></p></li><li><p>Partial index only has pointers to records having the field of interest.</p><p></p></li><li><p>Useful in applications such as an airline reservation system that need to access particular records quickly, but rarely need to process them sequentially.</p><p></p></li></ol>
New cards
19

What does a direct or hash file do?

When is it useful?

  • Turn key value into an address to support direct access of records in the file

  • Gives very rapid access to data

  • Useful if records are only accessed one at a time

New cards
20

How are indexes often implemented?

As B trees for low height

New cards
21

What information does the directory contain?

  1. info about files

    1. attributes

    2. location

    3. ownership

  2. Itself, directory is a file owned by the OS

New cards
22

What structure is used for storing the file directory?

tree structure (at top is master, beneath are users)

New cards
23

In a multiuser system, files should be able to be shared between users, giving us two issues….

  1. Access rights

  2. Simultaneous access

New cards
24
New cards
25
New cards
26

What rights does the owner have to a file?

all access rights and may grant rights to others

New cards
27

Access rights may be given to different classes of users.

Typical classes are….

  1. Specific user

  2. a group of users

  3. All

New cards
28

How do file sharing access rights work?

these rights constitute a hierarchy with higher level rights including the lower level ones

New cards
29

When does the OS or file management system must enforce discipline?

When access is granted to append or update a file to more than one user

New cards
30

How may the OS or file management system enforce discipline?

  1. Lock the entire file when it is to be updated

  2. Another approach is to lock individual records during update

New cards
31

Users work with a logical view of a file as a set of records.

How does the I/O view the file?

physical view; as a set of blocks

New cards
32

When we write to data, what happens?

What about if we read it?

blocking of records occur

unlocking is performed

New cards
33

Blocking considerations

  1. The larger the block, the more records that are passed in a single I/O

  2. For sequential access this reduces I/O’s, but may result in unnecessary data transfer for random access.

  3. Typically blocks are of fixed length to simplify the I/O transfer.

New cards
34

List the blocking methods

  1. Fixed

  2. Variable-length spanned

  3. Variable-length unspanned

New cards
35

Explain fixed blocking method

  • fixed length records

  • may cause internal fragmentation

<ul><li><p>fixed length records </p><p></p></li><li><p>may cause internal fragmentation</p></li></ul>
New cards
36

Explain variable length spanned blocking method

  • variable length records which may span blocks

  • permits unlimited record size

  • may require multiple I/Os

<ul><li><p>variable length records which may span blocks </p></li><li><p>permits unlimited record size</p></li><li><p>may require multiple I/Os</p></li></ul>
New cards
37

Explain variable-length unspanned blocking method

  • variable-length records which do not span blocks

  • may cause internal fragmentation

<ul><li><p>variable-length records which do not span blocks</p></li><li><p>may cause internal fragmentation</p></li></ul>
New cards
38

A file consists of a collection of blocks on what device?

secondary storage device

New cards
39

What manages the blocks?

OS/file management system

New cards
40

What are two management issues when it comes to managing blocks on the secondary storage device?

  1. Allocating blocks to files

  2. Maintaining a list of free blocks

New cards
41

File allocation issues

  1. Whether to allocate the maximum space required all at once, or to allocate space in portions.

  2. If portions are used, how big should a portion be?

  3. If portions are used, how to keep track of the portions.

New cards
42

What does preallocation require?

max file size be declared and allocated when the file is created (leads to overrequesting)

New cards
43

What does dynamic allocation allow?

ports of space to be given to the file so it can grow dynamically (but keeping track of seaprate pieces is hard)

New cards
44

Allocation Portion size methods

  1. Large, variable-length contiguous portion

    1. good performance

    2. may cause fragmenetation

    3. simple allocation table with pointer to beginning and length

  2. Small fixed-sized blocks

    1. good flexbility

    2. requires more complicated allocation table to keep track of non-contiguous blocks

New cards
45

Three methods of file allocation

  1. Contiguous allocation

    1. a single contiguous set of blocks is allocated to a file at the time of file creation.  Thus, this is a preallocation method of a variable-size portion.  May require periodic compaction due to fragmentation.  Good for sequential file access.

  2. Chained allocation

    1. allocate individual blocks.  Each block contains a pointer to the next block.

  3. Indexed allocation

    1. an index specifies the location of each block.

New cards
46

What does the disk allocation table do?

What are its techniques?

keeps track of available space (need to know to perform allocations)

  • bit tables

    • each bit represents a block

  • chained free portions

    • free portions are chained together

  • indexing

    • index keeps track of every free portion as if it was a file

  • Free block list

    • blocks are numbered and list of free block numbers is maintained

New cards
robot