1 chapter 12 file management overview file organisation and access file directories file sharing...
Post on 20-Dec-2015
266 views
TRANSCRIPT
![Page 1: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/1.jpg)
1
Chapter 12File Management
• Overview• File organisation and Access
• File Directories
• File Sharing
• Record Blocking
![Page 2: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/2.jpg)
2
Files
• Files are the central element to most applications– file as an input to applications– file as an output for long-term storage and for
later access
• Desirable properties of files:– Long-term existence– Controlled sharing between processes – Structure that is convenient for particular
applications
![Page 3: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/3.jpg)
3
File StructureFields and Records
• Fields– Basic element of data
• e.g., student’s last name
– Contains a single value– Characterized by its length and data type
• Records– Collection of related fields
• e.g., a student record
– Treated as a unit
![Page 4: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/4.jpg)
4
File StructureFile and Database
• File– Collection of similar records– Treated as a single entity and may be
referenced by name– Access control restrictions usually apply at the
file level
• Database– Collection of related data– Explicit relationships exist among elements– Consists of one or more files
![Page 5: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/5.jpg)
5
Roadmap
• Overview
• File organisation and Access• File Directories
• File Sharing
• Record Blocking
![Page 6: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/6.jpg)
6
File Organization
• The basic operations that a user or application may perform on a file are performed at the record level– The file is viewed as having some structure
that organizes the records
• File organization refers to the logical structuring of records– Determined by the way in which files are
accessed (access method)
![Page 7: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/7.jpg)
7
Criteria for File Organization
• Important criteria include:
– Short access time
– Ease of update
– Economy of storage
– Simple maintenance
– Reliability
![Page 8: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/8.jpg)
8
Criteria for File Organization
• Priority will differ depending on the use– For batch mode file processing, rapid access
for retrieval of a single record is of minimal concern
• These criteria may conflict– Use of indexes (conflict with economy of
storage) can be a primary means of increasing the speed of access to data
![Page 9: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/9.jpg)
9
The Pile
• Data are collected in the order they arrive– No structure
• Purpose is to accumulate a mass of data and save it
• Records may have different fields– field should be self-describing– field length should be known
![Page 10: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/10.jpg)
10
The Pile• Record access is by exhaustive search• Used when data are collected and stored
prior to processing or data are not easy to organize
• Uses space well when data vary in size and structure
• Adequate for exhaustive searches• Easy to update• Unsuitable for most applications
![Page 11: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/11.jpg)
11
The Sequential File
• Fixed format used for records
• Records are of the same length
– same number of fixed-length fields
in a particular order
• Only the values of fields need to
be stored
• Field name and length are
attributes of the file structure
![Page 12: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/12.jpg)
12
The Sequential File
• Key field– Uniquely identifies the record
– Records are stored in key sequence
• Optimal for batch applications if they involve the processing of all the records
• Easily stored on tape and disk
• Poor performance for interactive applications– considerable processing and delay due to the
sequential search of the file for a key match
![Page 13: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/13.jpg)
13
Indexed Sequential File
• An index is added to support random access– The index is a sequential file
– An index record contains a key field and a pointer into the main file
– For searching• Search the index to find the highest
key value that is equal to or precedes the desired key value
• Search continues in the main file at the location indicated by the pointer
![Page 14: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/14.jpg)
14
• An overflow file is added
• A new record is added to the overflow file and is
located by following a pointer from its predecessor
record
• The indexed sequential file is occasionally merged
with the overflow file in batch mode
Indexed Sequential File
![Page 15: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/15.jpg)
15
Indexed File• Records are accessed only through
their indexes– no restriction on the placement of
records
– allows variable-length records • Uses multiple indexes for different key
fields– An exhaustive index contains one entry for
every record in the main file– A partial index contains entries to records
where the field of interest exists
![Page 16: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/16.jpg)
16
Indexed File• When a new record is added to the main file, all
of the index files must be updated.
• Used mostly in applications where
– timeliness of information is critical and
– data are rarely processed exhaustively
– examples: airline reservation systems and inventory
control systems
![Page 17: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/17.jpg)
17
Roadmap
• Overview
• File organisation and Access
• File Directories• File Sharing
• Record Blocking
![Page 18: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/18.jpg)
18
File Directory
• Contains information about files
– Attributes
– Location
– Ownership
• Directory itself is a file owned by the
operating system
![Page 19: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/19.jpg)
19
Directory Elements
• Basic Information– File name: must be unique
– File type: e.g., text, binary
– File organization
• Address Information– Volume: device on which file is stored
– Starting address: e.g., cylinder, track on disk
– Size used: in bytes, words or blocks
– Size allocated: maximum size of the file
![Page 20: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/20.jpg)
20
Directory Elements
• Access Control Information– Owner: able to grant/deny access to other users and
to change these privileges– Access information: e.g., user’s name and password
for each authorized user– Permitted actions: controls reading, writing, executing,
transmitting over a network
• Usage Information– Date Created, Identity of Creator, Date Last Read
Access, Identity of Last Reader, Date Last Modified
![Page 21: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/21.jpg)
21
Hierarchical, or Tree-Structured Directory
• Master directory with user directories underneath it
• Each user directory may have subdirectories and files as entries
• Each directory and subdirectory can be organized as a sequential file
![Page 22: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/22.jpg)
22
Naming
• The tree structure allows users to find a file by following a path from the root or master directory down various branches until the file is reached
• The series of directory names, culminating in the file name itself, constitutes a pathname for the file
• Duplicate filenames are possible if they have different pathnames
![Page 23: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/23.jpg)
23
Naming
• Usually an interactive user or a process is associated with a current or working directory– Files are referenced
relative to the working directory unless an explicit full pathname is used
![Page 24: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/24.jpg)
24
Roadmap
• Overview
• File organisation and Access
• File Directories
• File Sharing• Record Blocking
![Page 25: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/25.jpg)
25
File Sharing
• In multiuser system, there is almost
always a requirement for allowing files to
be shared among a number of users
• Two issues
– Access rights
– Management of simultaneous access
![Page 26: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/26.jpg)
26
Access Rights
• A wide variety of access rights have been used by various systems– often as a hierarchy, with each right implying
those that precede it.
• None– User may not even know of the files existence
• Knowledge– User can only determine that the file exists
and who its owner is
![Page 27: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/27.jpg)
27
Access Rights cont…
• Execution– The user can load and execute a program but
cannot copy it
• Reading– The user can read the file for any purpose,
including copying and execution
• Appending– The user can add data to the file but cannot
modify or delete any of the file’s contents
![Page 28: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/28.jpg)
28
Access Rights cont…
• Updating– The user can modify, delete, and add to the
file’s data.
• Changing protection– User can change access rights granted to
other users
• Deletion– User can delete the file
![Page 29: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/29.jpg)
29
User Classes
• Owner– Usually the files creator, has full rights and may
grant rights to others
• Specific Users– Individual users who are designated by user ID
• User Groups– A set of users identified as a group
• All– All users who have access to this system
![Page 30: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/30.jpg)
30
Simultaneous Access
• When access is granted to append or update a file to more than one user, the OS or file management system must enforce discipline
• User may lock the entire file or individual records during update
• Mutual exclusion and deadlock are issues for shared access
![Page 31: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/31.jpg)
31
Roadmap
• Overview
• File organisation and Access
• File Directories
• File Sharing
• Record Blocking
![Page 32: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/32.jpg)
32
Blocks and records
• Records are the logical unit of access of a structured file
• Blocks are the unit for I/O with secondary storage
• Three methods of blocking are common– Fixed length blocking– Variable length spanned blocking– Variable-length unspanned blocking
![Page 33: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/33.jpg)
33
Fixed Blocking
• Fixed-length records are used, and an integral number of records are stored in a block
• Unused space at the end of a block is internal fragmentation
• Common for sequential files with fixed-length records
![Page 34: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/34.jpg)
34
Fixed Blocking
![Page 35: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/35.jpg)
35
Variable Length Spanned Blocking
• Variable-length records are used and are
packed into blocks with no unused space
• Some records may span multiple blocks
– Continuation is indicated by a pointer to the
successor block
• Efficient for storage and does not limit
the size of records
![Page 36: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/36.jpg)
36
Variable Blocking: Spanned
• Difficult to implement
• Records that span two blocks require two I/O operations
![Page 37: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/37.jpg)
37
Variable-length unspanned blocking
• Uses variable length records without spanning
• Wasted space in most blocks because of the inability to use the remainder of a block if the next record is larger than the remaining unused space
• Limits record size to the size of a block
![Page 38: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/38.jpg)
38
Variable Blocking: Unspanned
![Page 39: 1 Chapter 12 File Management Overview File organisation and Access File Directories File Sharing Record Blocking](https://reader033.vdocuments.net/reader033/viewer/2022061614/56649d435503460f94a1e9e5/html5/thumbnails/39.jpg)
39
A Big Picture
Describes the location of all files plus their attributes
Only authorized users are allowed to access particular
files in particular ways
Records must be organized as a sequence of blocks for output and unblocked after input
individual block I/O requests must be
scheduled for optimizing performance
User views the file as having some structure that
organizes the records; different access methods
reflect different file structures