0% found this document useful (0 votes)
22 views22 pages

Lec 6

Operating System

Uploaded by

John
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views22 pages

Lec 6

Operating System

Uploaded by

John
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

File and Database Systems

 2004 Deitel & Associates, Inc. All rights reserved.


Objectives

• After finishing this lecture, you should understand:


– the need for file systems.
– files, directories and the operations that can be performed on
them.
– organizing and managing a storage device’s data and free space.
– controlling access to data in a file system.
– backup, recovery and file system integrity mechanisms.
– database systems and models.

 2004 Deitel & Associates, Inc. All rights reserved.


13.1 Introduction

• Files
– Named collection of data that is manipulated as a unit
– Reside on secondary storage devices
• Operating systems can create an interface that
facilitates navigation of a user’s files
– File systems can protect such data from corruption or total loss
from disasters
– Systems that manage large amounts of shared data can benefit
from databases as an alternative to files

 2004 Deitel & Associates, Inc. All rights reserved.


13.2 Data Hierarchy

• Information is stored in computers according to a data


hierarchy.
• Lowest level of data hierarchy is composed of bits
– Bit patterns represent all data items of interest in computer systems

 2004 Deitel & Associates, Inc. All rights reserved.


13.2 Data Hierarchy

• Next level in the data hierarchy is fixed-length patterns of bits


such as bytes, characters and words
– Byte: typically 8 bits
– Word: the number of bits a processor can operate on at once
– Characters map bytes (or groups of bytes) to symbols such as letters,
numbers, punctuation and new lines
• Three most popular character sets in use today: ASCII, EBCDIC and
Unicode
– Field: a group of characters
– Record: a group of fields
– File: a group of related records

 2004 Deitel & Associates, Inc. All rights reserved.


13.2 Data Hierarchy

• Highest level of the data hierarchy is a file system or


database
• A volume is a unit of data storage that may hold
multiple files

 2004 Deitel & Associates, Inc. All rights reserved.


13.3 Files

• File: a named collection of data that may be


manipulated as a unit by operations such as:
– Open-prepare it to be referenced
– Close-prevent further reference
– Create-spawn a new file
– Destroy-delete a file
– Copy-duplicate a file
– Rename-give name to a file
– List-display the content of a file

 2004 Deitel & Associates, Inc. All rights reserved.


13.3 Files

• Individual data items within a file may be manipulated by


operations like:
– Read-copy file content to process’s memory
– Write-copy content from process’s memory to a file
– Update-modify
– Insert- add new content to a file
– Delete-remove data item from the file
• File characteristics include:
– Location
– Accessibility
– Type-file extension
– Volatility-frequency with which addition and deletion are made to file
– Activity-% of a file’s records accessed during a given period of time
• Files can consist of one or more records

 2004 Deitel & Associates, Inc. All rights reserved.


13.4 File Systems

• File systems
– Organize files and manages access to data
– Responsible for file management, auxiliary storage management,
file integrity mechanisms and access methods
– Primarily are concerned with managing secondary storage space,
particularly disk storage

 2004 Deitel & Associates, Inc. All rights reserved.


13.4 File Systems

• File system characteristics


– Should exhibit device independence:
• Users should be able to refer to their files by symbolic names
rather than having to use physical device names
– Should also provide backup and recovery capabilities to prevent
either accidental loss or malicious destruction of information
– May also provide encryption and decryption capabilities to make
information useful only to its intended audience

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories

• Directories:
– Files containing the names and locations of other files in the file
system, to organize and quickly locate files
• Directory entry stores information such as:
– File name
– Location
– Size
– Type
– Accessed
– Modified and creation times

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories

Figure 13.1 Directory file contents example.

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories

• Single-level (or flat) file system:


– Simplest file system organization
– Stores all of its files using one directory
– No two files can have the same name
– File system must perform a linear search of the directory
contents to locate each file, which can lead to poor performance

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories

• Hierarchical file system:


– A root indicates where on the storage device the root directory
begins
– The root directory points to the various directories, each of
which contains an entry for each of its files
– File names need be unique only within a given user directory
– The name of a file is usually formed as the pathname from the
root directory to the file

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories
Figure 13.2 Two-level hierarchical file system.

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories

• Working directory
– Simplifies navigation using pathnames
– Enables users to specify a pathname that does not begin at the
root directory (i.e., a relative path)
– Absolute path (i.e., the path beginning at the root) = working
directory + relative path

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories
Figure 13.3 Example hierarchical file system contents.

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories

• Link: a directory entry that references a data file or directory


located in a different directory
– Facilitates data sharing and can make it easier for users to access files
located throughout a file system’s directory structure
– Soft link: directory entry containing the pathname for another file
– Hard link: directory entry that specifies the location of the file
(typically a block number) on the storage device

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories

• Links (Cont.)
– Because a hard link specifies a physical location of a file, it references
invalid data when the physical location of its corresponding file
changes
– Because soft links store the logical location of the file in the file
system, they do not require updating when file data is moved
– However, if a user moves a file to different directory or renames the
file, any soft links to that file are no longer valid

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.1 Directories
Figure 13.4 Links in a file system.

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.2 Metadata

• Metadata
– Information that protects the integrity of the file system
– Cannot be modified directly by users
• Many file systems create a superblock to store critical
information that protects the integrity of the file
system
– A superblock might contain:
• The file system identifier
• The location of the storage device’s free blocks
– To reduce the risk of data loss, most file systems distribute
redundant copies of the superblock throughout the storage device

 2004 Deitel & Associates, Inc. All rights reserved.


13.4.2 Metadata

• File open operation returns a file descriptor


– A non-negative integer index into the open-file table
• From this point on, access to the file is directed
through the file descriptor
• To enable fast access to file-specific information such
as permissions, the open-file table often contains file
control blocks, also called file attributes:
– Highly system-dependent structures that might include the file’s
symbolic name, location in secondary storage, access control
data and so on

 2004 Deitel & Associates, Inc. All rights reserved.

You might also like