I/O MANAGEMENT
&DISK SCHEDULING
File System
File Concept: A file is a collection of similar records. The file is
treated as a single entity by users and applications and may be
referred by name. Files have unique file names and may be
created and deleted. Restrictions on access control usually
apply at the file level.
A file is a container for a collection of information. The file
manager provides a protection mechanism to allow users
administrator how processes executing on behalf of different
users can access the information in a file. File protection is a
fundamental property of files because it allows different people
to store their information on a shared computer.
File represents programs and data. Data files may be numeric,
alphabetic, binary or alpha numeric. Files may be free form,
such as text files. In general, file is sequence of bits, bytes,
lines or records.
A common technique for implementing file types is to include
the type as part of the file name. the name is split into two
parts a name and an extension. Various file types are shown in
the following table.
File Structure: Four terms are commonly used for files
1. Field: A field is the basic element of data. An individual field
contains a single value such as employee name, date.
2. Record: A record is a collection of related fields that can be
treated as single unit by application programs. A record will be
variable length.
3. File: A file is a collection of records, a file treat as a single entity
by user and application programs.
4. Database: A database is a collection of related data which
consist of relationship the elements of the data
For example, a telephone book is analogous to a file. It contains a
list of records, each of which consists of three fields: name,
address, and telephone number.
File Attributes: A file has certain attributes which
vary from one operating system to another.
1. Name: Every file has a name by which it is referred.
2. Identifier: It is unique number that identifies the file within
the file system.
3. Type: This information is needed for those systems that
support different types of files.
4. Location: It is a pointer to a device & to the location of the
file on that device
5. Size: It is the current size of a file in bytes, words or blocks.
6. Protection: It is the access control information that
determines who can read, write & execute a file.
7. Time, date & user identification: It gives information
about time of creation or last modification & last use.
File Operations: Any file system provides not only a
means to store data organized as files, but a collection of
functions that can be performed on files. Typical
operations include the following:
1. Creating files: Two steps are necessary to create a file. First,
space must be found for the file in the file system. Secondly,
an entry must be made in the directory for the new file.
2. Reading a file: Data & read from the file at the current
position. The system must keep a read pointer to know the
location in the file from where the next read is to take place.
Once the read has been taken place, the read pointer is
updated.
3. Writing a file: Data are written to the file at the current
position. The system must keep a write pointer to know the
location in the file where the next write is to take place. The
write pointer must be updated whenever a write occurs.
4. Repositioning within a file: The directory is searched for the
appropriate entry & the current file position is set to a given
value. After repositioning data can be read from or written
into that position. Repositioning within a file does not need to
involve any actual I/O. this file operation is also known as a
file seek.
5. Deleting a file: To delete a file, we search the directory for
the required file. After deletion, the space is released so that it
can be reused by other files.
6. Truncating a file: the user may want to erase the contents of a
file but keep its [Link] than forcing the user to delete
the file and then recreate it, this function allows all attributes to
remain unchanged- except for file length- but lets the file be
reset to length zero and its file space released.
File Access Methods: Files store information. When it is
used, this information must be accessed and read into
computer memory. The information in the file can be accessed
in several ways.
1. Sequential Access: It is the simplest access method.
Information in the file is processed in order i.e. one record
after another. A process can read all the data in a file in order
starting from beginning but can’t skip & read arbitrarily from
any location. Sequential files can be rewound. It is
convenient when storage medium was magnetic tape rather
than disk.
Eg : A file consisting of 100 records, the current position of
read/write head is 45th record, suppose we want to read the
75th record then, it access sequentially from 45, 46, 47 ……..
74,
75. So the read/write head traverse all the records between 45
to 75.
2. Direct Access: A file is made up of fixed length-logical
records that allow programs to read & write records rapidly in
no particular order. This method can be used when disk are
used for storing files. This method is used in many
applications e.g. database systems. If an airline customer
wants to reserve a seat on a particular flight, the reservation
program must be able to access the record for that flight
directly without reading the records before it. In a direct
access file, there is no restriction in the order of reading or
writing.
For example, we can read block 14, then read block 50 & then
write block 7 etc. Direct access files are very useful for
immediate access to large amount of information.
3. Indexed Access: In this method an index is created
which contains a key field and pointers to the various
blocks. To find an entry in the file for a key value, we
first search the index and then use the pointer to
directly access a file and find the desired entry.
With large files, the index file itself may become too large
to be keep in memory. One solution is to create an index
for the index file. The primary index file would contain
pointers to
secondary index files, which would point to the actual
data items. Figure 2 shows a situation as implemented by
VMS (Virtual Memory Storage) index and relative files.
File Directories: Sometimes the file system consisting of
millions of files, at that situation it is very hard to manage the
files. To manage these files grouped these files and load one
group into one partition. Each partition is called a directory. A
directory structure provides a mechanism for organizing many
files in the file system.
Operation on the directories: the various operations that can
be performed on directory are:
• Searching for a file: we need to search a directory structure to
find the entry for a particular file. Since files have symbolic
names in a user-readable form and similar names may indicate
a relationship between files. We may want to able to find all
files whose names match a particular pattern.
• Create a file: new files are created and added to the
directory.
• Delete a file: when we do not require to use a particular file,
it is removed from the directory.
• List a directory: when we want to list all the files in a
particular directory, and the contents of directory entry for
each file in the list.
• Rename a file: Whenever we need to change the name of the
file, we can change the name.
• Traverse the file system: in a directory structure, we may
wish to access every directory, and every file within a
directory structure.
Directory Structure: The most common schemes for
defining the structure of the directory are:
(i) Single-level Directory: it is the simplest directory
structure. All files are contained in the same directory which is
easy to support and understand (figure 3) Directory
Advantages:
• Since it is a single directory, so its implementation is very easy.
• If the files are smaller in size, searching will become faster.
• The operations like file creation, searching, deletion, updating
is very easy in such a directory structure.
Disadvantages:
• There may chance of name collision because two files can not
have the same name.
• Searching will become time taking if the directory is large.
• The same type of files cannot be grouped together.
(ii) Two-level Directory: the disadvantage of single level
directory is the confusion of files names between different users.
The solution for this problem is to create a directory for each
user as shown in figure 4.
In the two-level directory structure, each user has his own user
files directory (UFD). Each user has similar structure but lists
only the files of a single user. When user login, the system’s
master file directory (MFD) is searched. The master file
directory is indexed by user name or account number and each
entry points to the user directory for that user.
When users refer to a particular file, only their own user file
directory is searched. Thus different users may have files with
the same name, as long as all file names within each user file
directory are unique.
Advantages:
• We can give full path like /User-name/directory-name.
• Different users can have same directory as well as file name.
• Searching of files become more easy due to path name and
user-grouping.
Disadvantages:
• A user is not allowed to share files with other users.
• Searching will become time taking if the directory is large.
• Two files of the same type cannot be grouped together in the
same user.
(iii) Tree- Structured Directory: the tree-structure allows
user to create their own subdirectories and organize their files
accordingly. The tree has a root directory. Every file in the
systems has a unique path name. A path is the path from the
root through all the subdirectories to a specified file. A
directory contains a set of files and or sub-directories.
Advantages:
• User can access other user’s files by specifying the path name
• User can create his own sub-directories.
• Searching becomes very easy; we can use both absolute path as
well as relative
Disadvantages:
• Every file does not fit into the hierarchical model; files may be
saved into multiple directories.
• We cannot share files.
• It is inefficient, because accessing a file may go under multiple
directories
Design Issues of an OS
The Various Design Issues
• Efficiency
• Robustness
• Flexibility
• Portability
• Security
• Compatibility
Efficiency
Operating system efficiency is characterized by the amount of
useful work accomplished by system compared to the time and
resources used.
The ratio of actual operating time to scheduled operating time
of a computer system. In time-sharing system, the ratio of user
time to the sum of user time plus system time.
Robustness
The word robust, when used with regard to computer software,
refers to an operating system or other program that performs
well not only under ordinary conditions but also under unusual
conditions that stress its designers' assumptions.
A major feature of Unix-like operating systems is their robustness.
That is, they can operate for prolonged periods (sometimes years)
without crashing (i.e., stopping operating) or requiring rebooting
(i.e., restarting). And although individual application programs
sometimes crash, they almost always do so without affecting other
programs or the operating system itself.
Flexibility
The ease with which a system or component can be modified for
use in application or environment other than those for which it was
designed.
Eg. The RAM Capacity of a desktop computer can be expanded
only if the hardware and OS were specifically designed to
accommodate it.
Portability
Portability is the ability to run a program on different platforms.
Portability of the OS means the operating system itself can be
run easily (after re-compilation) on a different hardware platform
Compatability
A family of computer models is said to be compatible if certain
software that runs on one of the models can also be run on all
other models of the family.
The main Compatibility goal for Windows 7 is to make sure that
most all applications which work on Windows Vista will
continue to work seamlessly on Windows 7
Security
One use of the term computer security refers to technology to
implement a secure operating system.
Microsoft operating system updates are releases of new
software that upgrade, add features to, and protect Microsoft
Windows, the software that runs your computer.
Design Issues of Distributed System
• Transparency - the distributed system should appear as a
conventional, centralized system to the user
• Fault tolerance - the distributed system should continue to
function in the face of failure
• Scalability- as demands increase, the system should easily
accept the addition of new resources to accommodate the
increased demand
• Clusters- a collection of semi-autonomous machines that
acts as a single system
Robustness
• Failure detection
• Reconfiguration
Failure Detection
• Detecting hardware failure is difficult
• To detect a link failure, a handshaking protocol can be used
• Assume Site A and Site B have established a link
-At fixed intervals, each site will exchange an I-am-up
message indicating that they are up and running
• If Site A does not receive a message within the fixed interval, it assumes
either (a) the other site is not up or (b) the message was lost
• Site A can now send an Are-you-up? message to Site B
• If Site A does not receive a reply, it can repeat the message or try an
alternate route to Site B
• If Site A does not ultimately receive a reply from Site B, it concludes
some type of failure has occurred
• Types of failures:
Site B is down
The direct link between A and B is down
The alternate link from A to B is down
The message has been lost
• However, Site A cannot determine exactly why the failure has occurred
Reconfiguration
• When Site A determines a failure has occurred, it must
reconfigure the system:
1. If the link from A to B has failed, this must be broadcast
to every site in the system
2. If a site has failed, every other site must also be notified
indicating that the services offered by the failed site are
no longer available
• When the link or the site becomes available again, this
information must again be broadcast to all other sites