Introduction To Operating Syst
Introduction To Operating Syst
Parallel Systems
Distributed Systems
Jobs with similar needs were batched together and were run through
the computer as a group.
Are appropriate for executing large jobs that need little interaction.
Spooling (Simultaneous peripheral operation on-line)
Use of Spooling
Here multiple jobs are executed by CPU switching between them, but
the switches occur so frequently that the users may interact with each
program while it is running.
Parallel Systems
1. Increased throughput
Failure of one processor will not halt the system, but rather will
only slow it down
Ability to continue providing service proportional to the level of
surviving hardware is called graceful degradation.
Systems that are designed for graceful degradation are also called
fault-tolerant.
Failure detection and correction
The system consists of two identical processors, each with its own
local memory. Connected with a help of a bus.
One, processor is the primary, and the other is the backup
At fixed checkpoints in the execution of the system, the state
information of each job (including a copy of the memory image) is
copied from the primary machine to the backup.
Distributed Systems
Interprocess Communication
Process Concept
Process Number
Program Counter
Registers
Memory Limits
Process Scheduling
Scheduling Queues
Ready queue: The processes that are residing in main memory and
are ready and waiting to execute
Process Scheduling
Schedulers
Switching the CPU to another process requires saving the state of the
old process loading the saved state for the new process
Operation on Processes
Process Termination
The child has exceeded its usage of some of the resources it has
been allocated.
The task assigned to the child is no longer required.
The parent is exiting, and the operating system does not allow a
child to continue if its parent terminates
Co-operating Processes
Computation speedup
Information sharing
Modularity
Convenience
Interprocess Communication
Sockets
Methods for logically implementing a link and the
send/receive operations:
Link properties:
Both the sender and the receiver processes have to name each other to
communicate.
The parent waits until some or all of its children have terminated
Processes (Unit -2)
Indirect Communication
Buffering
Mutual Exclusion
Critical Sections
Mutual Exclusion Primitives
Semaphores
Indirect Communication
Zero capacity: The queue has maximum length 0; thus, the link
cannot have any messages waiting in it.
Mutual Exclusion
Each process accessing the shared data excludes all others from doing
so simultaneously.
Critical Sections
This instruction, often called testandset, once initiated will complete all
of these functions without interruption. The indivisible testandset
instruction
Testandset (a, b)
Reads the value of boolean b, copies it into a, and then sets b to true -
all within the span of a single uninterruptable insturction.
Load store
Add store
CPU burst
Read from file
Store increment
Index
CPU burst
Write to file
CPU Schedulers
The dispatcher is the module that gives control of the CPU to the
process selected by the short-term scheduler
Function involves
Switching context
Switching to user mode
The process that requests the CPU first is allocated the CPU first.
Example: Given -Set of processes that arrive at time 0, with the length
of the CPU-burst time given in milliseconds
CPU time is assigned to the process that has the smallest CPU
burst.
FCFS scheduling is used to break the tie when two processes have
the same length next CPU burst.
Average waiting time is (3 + 16 + 9 + 0)/4 = 7 milliseconds
Preemptive SJF schedule
The CPU is allocated to the process with the highest priority Priority
scheduling can be either preemptive or nonpreemptive
Drawback:
Solution
Aging
System Model
Necessary Conditions for dead lock
Resource-Allocation Graph
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock situation
s
Necessary Conditions for a deadlock to occur
1. Mutual exclusion
3. No preemption
4. Circular wait
Resource-Allocation Graph
Assignment edge Rj Pi
Resource allocation picture
Deadlock-prevention
Deadlock-avoidance
Deadlock-detection
Deadlock-prevention
Mutual exclusion
Hold and wait
No preemption
Circular wait
Deadlock-prevention
Mutual Exclusion
o Make the resources Sharable
Starvation
No Preemption
Protocol used
F(Printer) = 12
Deadlock Avoidance
Changing state from safe to unsafe
Banker's Algorithm
Safety Algorithm
Resource-Request Algorithm
Deadlock Detection
Deadlock Avoidance
At time to, the system is in a safe state. The sequence <P 1, P0, P2>
satisfies the safety condition.
Say, at time t0, process P2 requests and is allocated 1 more tape drive
Reason
1. Consider Sequence <P1, P0, P2>, only process P1 can be allocated all its tape
drives.
2. When it returns them, the system will have only 4 available TAPE
drives
Banker's Algorithm
Data Structures
Max: If Max[i, j] =k, then Pi may request at most k instances of resource type Rj.
Need: If Need [i, j] = k, then Pi may need k more instances of resource type Rj to
complete its task.
Safety Algorithm
Several Instances of a Resource Type
Background
Overlays
Logical versus Physical Address Space
Swapping
Continuous Allocation
External and Internal Fragmentation
Paging
Segmentation
Compile time
Load time
Execution time
Dynamic Loading
Example
A two-pass assembler
Pass 1 Pass 2
Symbol Machine Common Routines
Table Language Code
Pass 1 70K
Pass 2 80K
Symbol Table 20K
Common Routines 30K
Overlay A
Pass 1 Overlay B
Symbol Pass 2
Table Machine Language Code
Common Common Routines
Routines
Diagram
Logical versus Physical Address Space
Continuous Allocation
Divisions of memory
1. First-fit:
Allocate the first hole that is big enough.
Searching can start
Compaction
Shuffle the memory contents to place all free memory together in one
large block
100K, 300K and 260K are merged to get 660K large free block.
Paging
Logical memory is also broken into blocks of the same size called
pages.
Segmentation
<segment-number(s), offset(d)>
Demand paging
Page Replacement Algorithm
Global Versus Local Allocation
Thrashing
Virtual memory
Virtual memory is a technique that allows the execution of
processes that may not be completely in memory.
A page trap occurs if the process tries to use a page that was not
brought, into memory
FIFO Algorithm
Optimal Algorithm
LRU Algorithm
FIFO Algorithm
It says
"Replace the page that will not be used for the longest period of time"
LRU Algorithm
"Replace the page that has not used for the longest period of time"
1. Global replacement
Allows a process to select a replacement frame from the set of all frames, even if
that frame is currently allocated to some other process
If the operating system sees that the CPU utilization is too low, introducing a new
process to the system increases the degree of multiprogramming.
A global page-replacement algorithm is used, replacing pages with no regard to th
process to which they belong
If process needs more frames, it starts faulting and taking pages away from other
processes
All process faulting queue up for the paging device, the ready queue empties with
reduction in CPU utilization.
Decreasing CPU utilization leads to increase in the degree of multiprogramming
News process tend to increase the paging further decrease in CPU utilization
The effects of thrashing can be limited by using a local (or priority) replacement algorith
Structure
8.1 Introduction
Objectives
Attributes of a File
Operations on Files
Types of Files
Structure of File
Sequential Access
Direct Access
Contiguous Allocation
Linked Allocation
Indexed Allocation
Performance Comparison
Bit Vector
Linked List
Grouping
Counting
Linear List
Hash Table
8.8 Summary
8.10 Answers
8.1 Introduction
The operating system is a resource manager. Secondary resources like the disk are also to
be managed. Information is stored in secondary storage because it costs less, is non-
volatile and provides large storage space. Processes access data / information present on
secondary storage while in execution. Thus, the operating system has to properly
organize data / information in secondary storage for efficient access.
The file system is the most visible part of an operating system. It is a way for on-line
storage and access of both data and code of the operating system and the users. It resides
on the secondary storage because of the two main characteristics of secondary storage,
namely, large storage capacity and non-volatile nature.
Objectives:
The concepts of Files, Different File access methods. Different directory structures, disk
space allocation methods, how to manage free space on the disk and implementation of
directory.
Users use different storage media such as magnetic disks, tapes, optical disks and so on.
All these different storage media have their own way of storing information. The
operating system provides a uniform logical view of information stored in these different
media. The operating system abstracts from the physical properties of its storage devices
to define a logical storage unit called a file. These files are then mapped on to physical
devices by the operating system during use. The storage devices are usually non-volatile,
meaning the contents stored in these devices persist through power failures and system
reboots.
A file has a name. The file name is a string of characters. For example, test.c, pay.cob,
master.dat, os.doc. In addition to a name, a file has certain other attributes. Important
attributes among them are:
· LocTypation: information is a pointer to a device and the location of the file on that
device.
· Time, date and user id: Information regarding when the file was created last modified
and last used. This information is useful for protection, security and usage monitoring.
All these attributes of files are stored in a centralized place called the directory. The
directory is big if the numbers of files are many and also requires permanent storage. It is
therefore stored on secondary storage.
A file is an abstract data type. Six basic operations are possible on files. They are:
1. Creating a file: two steps in file creation include space allocation for the file and an
entry to be made in the directory to record the name and location of the file.
2. Writing a file: parameters required to write into a file are the name of the file and the
contents to be written into it. Given the name of the file the operating system makes a
search in the directory to find the location of the file. An updated write pointer enables to
write the contents at a proper location in the file.
3. Reading a file: to read information stored in a file the name of the file specified as a
parameter is searched by the operating system in the directory to locate the file. An
updated read pointer helps read information from a particular location in the file.
4. Repositioning within a file: a file is searched in the directory and a given new value
replaces the current file position. No I/O takes place. It is also known as file seek.
5. Deleting a file: The directory is searched for the particular file, If it is found, file space
and other resources associated with that file are released and the corresponding directory
entry is erased.
6. Truncating a file: file attributes remain the same, but the file has a reduced size
because the user deletes information in the file. The end of file pointer is reset.
Other common operations are combinations of these basic operations. They include
append, rename and copy. A file on the system is very similar to a manual file. An
operation on a file is possible only if the file is open. After performing the operation, the
file is closed. All the above basic operations together with the open and close are
provided by the operating system as system calls.
The operating system recognizes and supports different file types. The most common way
of implementing file types is to include the type of the file as part of the file name. The
attribute ‘name’ of the file consists of two parts: a name and an extension separated by a
period. The extension is the part of a file name that identifies the type of the file. For
example, in MS-DOS a file name can be up to eight characters long followed by a period
and then a three-character extension. Executable files have a .com / .exe / .bat extension,
C source code files have a .c extension, COBOL source code files have a .cob extension
and so on.
If an operating system can recognize the type of a file then it can operate on the file quite
well. For example, an attempt to print an executable file should be aborted since it will
produce only garbage. Another use of file types is the capability of the operating system
to automatically recompile the latest version of source code to execute the latest modified
program. This is observed in the Turbo / Borland integrated program development
environment.
File types are an indication of the internal structure of a file. Some files even need to have
a structure that need to be understood by the operating system. For example, the structure
of executable files need to be known to the operating system so that it can be loaded in
memory and control transferred to the first instruction for execution to begin. Some
operating systems also support multiple file structures.
Operating system support for multiple file structures makes the operating system more
complex. Hence some operating systems support only a minimal number of files
structures. A very good example of this type of operating system is the UNIX operating
system. UNIX treats each file as a sequence of bytes. It is up to the application program
to interpret a file. Here maximum flexibility is present but support from operating system
point of view is minimal. Irrespective of any file structure support, every operating
system must support at least an executable file structure to load and execute programs.
Disk I/O is always in terms of blocks. A block is a physical unit of storage. Usually all
blocks are of same size. For example, each block = 512 bytes. Logical records have their
own structure that is very rarely an exact multiple of the physical block size. Therefore a
number of logical records are packed into one physical block. This helps the operating
system to easily locate an offset within a file. For example, as discussed above, UNIX
treats files as a sequence of bytes. If each physical block is say 512 bytes, then the
operating system packs and unpacks 512 bytes of logical records into physical blocks.
File access is always in terms of blocks. The logical size, physical size and packing
technique determine the number of logical records that can be packed into one physical
block. The mapping is usually done by the operating system. But since the total file size
is not always an exact multiple of the block size, the last physical block containing
logical records is not full. Some part of this last block is always wasted. On an average
half a block is wasted. This is termed internal fragmentation. Larger the physical block
size, greater is the internal fragmentation. All file systems do suffer from internal
fragmentation. This is the penalty paid for easy file access by the operating system in
terms of blocks instead of bits or bytes.
8.3 File Access Methods
Information is stored in files. Files reside on secondary storage. When this information is
to be used, it has to be accessed and brought into primary main memory. Information in
files could be accessed in many ways. It is usually dependent on an application. Access
methods could be :-
· Sequential access
· Direct access
In a simple access method, information in a file is accessed sequentially one record after
another. To process the ith record all the i-1 records previous to I must be accessed.
Sequential access is based on the tape model that is inherently a sequential access device.
Sequential access is best suited where most of the records in a file are to be processed.
For example, transaction files.
Sometimes it is not necessary to process every record in a file. It may not be necessary to
process records in the order in which they are present. Information present in a record of
a file is to be accessed only if some key value in that record is known. In all such cases,
direct access is used. Direct access is based on the disk that is a direct access device and
allows random access of any file block. Since a file is a collection of physical blocks, any
block and hence the records in that block are accessed. For example, master files.
Databases are often of this type since they allow query processing that involves
immediate access to large amounts of information. All reservation systems fall into this
category. Not all operating systems support direct access files. Usually files are to be
defined as sequential or direct at the time of creation and accessed accordingly later.
Sequential access of a direct access file is possible but direct access of a sequential file is
not.
This access method is a slight modification of the direct access method. It is in fact a
combination of both the sequential access as well as direct access. The main concept is to
access a file direct first and then sequentially from that point onwards. This access
method involves maintaining an index. The index is a pointer to a block. To access a
record in a file, a direct access of the index is made. The information obtained from this
access is used to access the file. For example, the direct access to a file will give the
block address and within the block the record is accessed sequentially. Sometimes
indexes may be big. So a hierarchy of indexes are built in which one direct access of an
index leads to info to access another index directly and so on till the actual file is
accessed sequentially for the particular record. The main advantage in this type of access
is that both direct and sequential access of files is possible.
Files systems are very large. Files have to be organized. Usually a two level organization
is done:
· The file system is divided into partitions. In Default there is at least one partition.
Partitions are nothing but virtual disks with each partition considered as a separate
storage device.
· Each partition has information about the files in it. This information is nothing but a
table of contents. It is known as a directory.
The directory maintains information about the name, location, size and type of all files in
the partition. A directory has a logical structure. This is dependent on many factors
including operations that are to be performed on the directory like search for file/s, create
a file, delete a file, list a directory, rename a file and traverse a file system. For example,
the dir, del, ren commands in MS-DOS.
This is a simple directory structure that is very easy to support. All files reside in one and
the same directory (Figure 8.1).
A single-level directory has limitations as the number of files and users increase. Since
there is only one directory to list all the files, no two files can have the same name, that
is, file names must be unique in order to identify one file from another. Even with one
user, it is difficult to maintain files with unique names when the number of files becomes
large.
The main limitation of single-level directory is to have unique file names by different
users. One solution to the problem could be to create separate directories for each user.
A two-level directory structure has one directory exclusively for each user. The directory
structure of each user is similar in structure and maintains file information about files
present in that directory only. The operating system has one master directory for a
partition. This directory has entries for each of the user directories (Figure 8.2).
Files with same names exist across user directories but not in the same user directory. File
maintenance is easy. Users are isolated from one another. But when users work in a group
and each wants to access files in another users directory, it may not be possible.
Access to a file is through user name and file name. This is known as a path. Thus a path
uniquely defines a file. For example, in MS-DOS if ‘C’ is the partition then
C:USER1TEST, C:USER2TEST, C:USER3C are all files in user directories. Files could
be created, deleted, searched and renamed in the user directories only.
A two-level directory is a tree of height two with the master file directory at the root
having user directories as descendants that in turn have the files themselves as
descendants(Figure 8.3). This generalization allows users to organize files within user
directories into sub directories. Every file has a unique path. Here the path is from the
root through all the sub directories to the specific file.
Usually the user has a current directory. User created sub directories could be traversed.
Files are usually accessed by giving their path names. Path names could be either
absolute or relative. Absolute path names begin with the root and give the complete path
down to the file. Relative path names begin with the current directory. Allowing users to
define sub directories allows for organizing user files based on topics. A directory is
treated as yet another file in the directory, higher up in the hierarchy. To delete a directory
it must be empty. Two options exist: delete all files and then delete the directory or delete
all entries in the directory when the directory is deleted. Deletion may be a recursive
process since directory to be deleted may contain sub directories.
Allocation of disk space to files is a problem that looks at how effectively disk space is
utilized and quickly files can be accessed. The three major methods of disk space
allocation are:
· Contiguous allocation
· Linked allocation
· Indexed allocation
Contiguous allocation requires a file to occupy contiguous blocks on the disk. Because of
this constraint disk access time is reduced, as disk head movement is usually restricted to
only one track. Number of seeks for accessing contiguously allocated files is minimal and
so also seek times.
A file that is ‘n’ blocks long starting at a location ‘b’ on the disk occupies blocks b, b+1,
b+2, ….., b+(n-1). The directory entry for each contiguously allocated file gives the
address of the starting block and the length of the file in blocks as illustrated below
(Figure 8.4).
Accessing a contiguously allocated file is easy. Both sequential and random access of a
file is possible. If a sequential access of a file is made then the next block after the current
is accessed, whereas if a direct access is made then a direct block address to the ith block
is calculated as b+i where b is the starting block address.
A major disadvantage with contiguous allocation is to find contiguous space enough for
the file. From a set of free blocks, a first-fit or best-fit strategy is adopted to find ‘n’
contiguous holes for a file of size ‘n’. But these algorithms suffer from external
fragmentation. As disk space is allocated and released, a single large hole of disk space is
fragmented into smaller holes. Sometimes the total size of all the holes put together is
larger than the size of the file size that is to be allocated space. But the file cannot be
allocated space because there is no contiguous hole of size equal to that of the file. This is
when external fragmentation has occurred. Compaction of disk space is a solution to
external fragmentation. But it has a very large overhead.
Another problem with contiguous allocation is to determine the space needed for a file.
The file is a dynamic entity that grows and shrinks. If allocated space is just enough (a
best-fit allocation strategy is adopted) and if the file grows, there may not be space on
either side of the file to expand. The solution to this problem is to again reallocate the file
into a bigger space and release the existing space. Another solution that could be possible
if the file size is known in advance is to make an allocation for the known file size. But in
this case there is always a possibility of a large amount of internal fragmentation because
initially the file may not occupy the entire space and also grow very slowly.
Initially a block is allocated to a file, with the directory having this block as the start and
end. As the file grows, additional blocks are allocated with the current block containing a
pointer to the next and the end block being updated in the directory.
This allocation method does not suffer from external fragmentation because any free
block can satisfy a request. Hence there is no need for compaction. moreover a file can
grow and shrink without problems of allocation.
Linked allocation has some disadvantages. Random access of files is not possible. To
access the ith block access begins at the beginning of the file and follows the pointers in
all the blocks till the ith block is accessed. Therefore access is always sequential. Also
some space in all the allocated blocks is used for storing pointers. This is clearly an
overhead as a fixed percentage from every block is wasted. This problem is overcome by
allocating blocks in clusters that are nothing but groups of blocks. But this tends to
increase internal fragmentation. Another problem in this allocation scheme is that of
scattered pointers. If for any reason a pointer is lost, then the file after that block is
inaccessible. A doubly linked block structure may solve the problem at the cost of
additional pointers to be maintained.
MS-DOS uses a variation of the linked allocation called a file allocation table (FAT). The
FAT resides on the disk and contains entry for each disk block and is indexed by block
number. The directory contains the starting block address of the file. This block in the
FAT has a pointer to the next block and so on till the last block (Figure 8.6). Random
access of files is possible because the FAT can be scanned for a direct block address.
Each file has an index block. The address of this index block finds an entry in the
directory and contains only block addresses in the order in which they are allocated to the
file. The ith address in the index block is the ith block of the file (Figure 8.7). Here both
sequential and direct access of a file are possible. Also it does not suffer from external
fragmentation.
Figure 8.7: Indexed Allocation
Indexed allocation does suffer from wasted block space. Pointer overhead is more in
indexed allocation than in linked allocation. Every file needs an index block. Then what
should be the size of the index block? If it is too big, space is wasted. If it is too small,
large files cannot be stored. More than one index blocks are linked so that large files can
be stored. Multilevel index blocks are also used. A combined scheme having direct index
blocks as well as linked index blocks has been implemented in the UNIX operating
system.
All the three allocation methods differ in storage efficiency and block access time.
Contiguous allocation requires only one disk access to get a block, whether it be the next
block (sequential) or the ith block (direct). In the case of linked allocation, the address of
the next block is available in the current block being accessed and so is very much suited
for sequential access. Hence direct access files could use contiguous allocation and
sequential access files could use linked allocation. But if this is fixed then the type of
access on a file needs to be declared at the time of file creation. Thus a sequential access
file will be linked and cannot support direct access. On the other hand a direct access file
will have contiguous allocation and can also support sequential access, the constraint in
this case is making known the file length at the time of file creation. The operating
system will then have to support algorithms and data structures for both allocation
methods. Conversion of one file type to another needs a copy operation to the desired file
type.
Some systems support both contiguous and linked allocation. Initially all files have
contiguous allocation. As they grow a switch to indexed allocation takes place. If on an
average files are small, than contiguous file allocation is advantageous and provides good
performance.
A bit map or a bit vector is a very common way of implementing a free-space list. This
vector ‘n’ number of bits where ‘n’ is the total number of available disk blocks. A free
block has its corresponding bit set (1) in the bit vector whereas an allocated block has its
bit reset (0).
Illustration: If blocks 2, 4, 5, 9, 10, 12, 15, 18, 20, 22, 23, 24, 25, 29 are free and the rest
are allocated, then a free-space list implemented as a bit vector would look as shown
below:
00101100011010010010101111000100000………
The advantage of this approach is that it is very simple to implement and efficient to
access. If only one free block is needed then a search for the first ‘1’ in the vector is
necessary. If a contiguous allocation for ‘b’ blocks is required, then a contiguous run of
‘b’ number of 1’s is searched. And if the first-fit scheme is used then the first such run is
chosen and the best of such runs is chosen if best-fit scheme is used.
Bit vectors are inefficient if they are not in memory. Also the size of the vector has to be
updated if the size of the disk changes.
All free blocks are linked together. The free-space list head contains the address of the
first free block. This block in turn contains the address of the next free block and so on.
But this scheme works well for linked allocation. If contiguous allocation is used then to
search for ‘b’ contiguous free blocks calls for traversal of the free-space list which is not
efficient. The FAT in MS-DOS builds in free block accounting into the allocation data
structure itself where free blocks have an entry say –1 in the FAT.
8.6.3 Grouping
Another approach is to store ‘n’ free block addresses in the first free block. Here (n-1)
blocks are actually free. The last nth address is the address of a block that contains the
next set of free block addresses. This method has the advantage that a large number of
free block addresses are available at a single place unlike in the previous linked approach
where free block addresses are scattered.
8.6.4 Counting
If contiguous allocation is used and a file has freed its disk space then a contiguous set of
‘n’ blocks is free. Instead of storing the addresses of all these ‘n’ blocks in the free-space
list, only the starting free block address and a count of the number of blocks free from
that address can be stored. This is exactly what is done in this scheme where each entry in
the free-space list is a disk address followed by a count.
· Linear list
· Hash table
A linear list of file names with pointers to the data blocks is one way to implement a
directory. A linear search is necessary to find a particular file. The method is simple but
the search is time consuming. To create a file, a linear search is made to look for the
existence of a file with the same file name and if no such file is found the new file created
is added to the directory at the end. To delete a file, a linear search for the file name is
made and if found allocated space is released. Every time making a linear search
consumes time and increases access time that is not desirable since a directory
information is frequently used. A sorted list allows for a binary search that is time
efficient compared to the linear search. But maintaining a sorted list is an overhead
especially because of file creations and deletions.
Another data structure for directory implementation is the hash table. A linear list is used
to store directory entries. A hash table takes a value computed from the file name and
returns a pointer to the file name in the linear list. Thus search time is greatly reduced.
Insertions are prone to collisions that are resolved. The main problem is the hash function
that is dependent on the hash table size. A solution to the problem is to allow for chained
overflow with each hash entry being a linked list. Directory lookups in a hash table are
faster than in a linear list.
8.8 Summary
In this chapter the operating system as a secondary resource manager has been studied.
Data / information stored in secondary storage has to be managed and efficiently accessed
by executing processes. To do this the operating system uses the concept of a file. A file is
the smallest allotment of secondary storage. Any information to be stored needs to be
written on to a file. We have studied file attributes, operations on files, types and structure
of files, File access methods, File Allocation methods and implementation of a file. We
have also learnt the concept of a directory, its various structures for easy and protected
access of files and its implementation.
2. ___________ is best suited access method where most of the records in a file are to be
processed.
4. What is the need for a directory? Explain the different directory structures.
Structure
9.1 Introduction
Objectives
9.2 Characteristics of Distributed Processing
Distributed Applications
Distribution of Data
Distribution of Control
Redirection
Communication Management
Migration
Types of services
RPC
Calling Procedure
Parameter Representation
Ports
9.12 Answers
9.1 Introduction
Earlier were the days of centralized computing. With the advent of micro and mini
computers, distributed processing is becoming more and more popular. Merely having a
large central computer with a number of remote terminals connected to it or with a
number of computers at different locations with no connection among them do not
constitute a distributed processing because neither processing nor data is distributed in
any sense.
Operating systems have moved from single process systems to single processor, multi-
user, and multitasking systems. Today the trend is towards multiprocessor, multitasking
systems. Distributed processing and parallel processing are two technologies used to
harness the power of a multiprocessor system. A proper mix of the technologies may
yield better results.
Distributed processing and parallel processing have a common goal – high throughput
using more processors. Then why not use a faster processor? It is difficult to achieve
higher throughput out of hardware just by increasing speed of the processor. Moreover
faster processors mean high costs. Higher throughput was envisaged by using the
available microprocessors and interconnecting them. This is called distributed processing
or loosely coupled system. In parallel processing or tightly coupled systems there is only
one computer with multiple CPUs. The operating system here is responsible for load
distribution, communication and co-ordination.
Objectives:
· About Global Operating System, Remote Procedure Call and Distributed File
Management.
· All processors are tightly coupled, use shared memory for communication and are
present in one case.
· Any processor can execute any job. All processors are similar.
· Horizontal distribution
· Centralized data
· Replicated data
· Partitioned data
In centralized data, data resides only at one central computer that can be accessed or
shared by all other computers in the network. For example, master database. This central
computer must run an operating system that implements functions of information
management. It must keep track of users and their files and handle data sharing,
protection, disk space allocation and other related issues. It must also run a front-end
software for receiving requests / queries from other computers for data. These requests
are then serviced one by one. It is because of this software that this central computer is
called a server. Computers connected to the server can have their own local data but
shared data has to necessarily reside in the server. In a distributed environment, part of
the master database could be centralized and the rest distributed among the connecting
computers.
Sometimes a particular database is required very often at each computer in the network.
If it is stored only in a central computer, as above, transmitting it from the server to local
computers when required is time consuming and an unwanted exercise because the
current state of the database may not have changed from a previous state. In such cases,
the specific database can be replicated or duplicated in the computer where it is needed
often. But to maintain data coherence when part of the database has been updated, the
modifications have to be reflected in all the places where it has been duplicated. For
example, information about train timings and fares would need replication because this
information is needed at all terminals which cater to train bookings / reservations /
enquires, the reason being frequency of changes to this particular database is very low.
Data could be distributed in a partitioned way. The entire database is sliced into many
parts. Each part of the database then resides on a computer. Processing depends upon the
kind of data distribution. Any other computer wanting to access information / data present
not locally but at a remote site must send a query and receive the contents needed. If such
is the case then each computer will run front-end software to receive queries and act a
server for the data stored in it.
The architecture of typical NOS is shown below (Figure 9.1). The basic features in any
NOS are explained by tracing the steps involved in a remote read. It is assumed that
shared data resides on the server and clients are those computers in the network (other
than the server) that want to access the shared data.
· A system call generated by an application program not related to any I/O function is
handled by the local operating system (LOS) running on the client.
· If the request is for remote data then the call has to be processed as a remote procedure
call (RPC) from the client to the server. In response to this request, data traverses back to
the client from the server. Communication management software handles the request for
data and the actual data. This software resides both on the server as well as the client and
ensures that a message is communicated between client and the server without any error
and implements network functions such as packetizing, routing, error and flow control.
· For a remote request the redirection software on the client sends a request to the
communication management software on the client.
· The communication management software on the client generates a RPC and sends it
across the network.
· The communication management software on the server receives the request and in turn
requests the network services software on the server itself for the clients request. This
software is responsible for sharable resources such as files, disks, databases and printers.
The software receives many such requests from different clients, generates a task for each
one of them and schedules them for service. Thus NOS implements some kind of
multitasking to service multiple tasks. Since network services software accesses shared
resources, access control and protection are implemented.
· The network services software on the server communicates with the information
management module of the operating system running on the server to get the requested
data. Two approaches are possible. In one approach, capabilities of information
management are built into the NOS such as in NetWare. In the other approach, a separate
operating system such as UNIX runs on the server and the network services software
module of the NOS generates calls to the operating system, in this case, UNIX running
on the server for required data.
· The network services software on the server sends the required data to the
communication management software on the server to be sent to the client.
· The communication management software on the client now sends the received data to
the application program so that it proceeds.
· Redirection
· Communication management
· Network management
9.6.1 Redirection
Redirection software normally resides on the client and also on the server. On the server
also because, if it is not a dedicated one then user of the server machine may want access
to other computers. When does the redirection software actually work? An interrupt is
executed by a system call generated, say for an I/O. It is at the time of execution of the
interrupt that redirection software intercepts to check if the I/O is local / remote. If it is
local, processing continues. If it is remote the redirection software has to generate a
request to the server. But generating a request to the server has problems. The operating
system running on the server may be different from that on the local machine generating
the request. Also system architecture of the server may be different from the client.
Therefore some conversion is necessary.
File / printer resources are controlled by these services. This software runs only on the
server. Requests for shared resources are queued up, scheduled and then run as separate
tasks, thus making the NOS a multitasking operating system.
Network management software is responsible for monitoring the network and its
components such as computers, modems, repeaters, lines, adapters, multiplexers and
many more. Special software enables online testing of these equipment from time to time,
checks their status and hence monitors the entire network. The network management
software is responsible for all this. It maintains a list of hardware equipment along with
its location and status. The list is updated when additional equipment is added or when
equipment is down for repair. It generates reports based on which action can be taken in
terms of repair / replacements. It helps routing algorithms to route data on appropriate
paths. The network management software resides on top of the existing operating system
in ordinary operating systems. But in a NOS environment it is part of the NOS.
The NOS is responsible for activities such as memory and process management on the
server. The NOS converts a request into a task, schedules and executes it. Memory and
processing power in all other computers in the network is not tapped to the maximum by
a NOS. This is exactly what the GOS attempts to do. It has a list of processes executing
on different machines and the resources needed by each one of them. Relatively free
processors can be scheduled with tasks for execution. Memory is managed at a global
level. The various functions of the GOS are:
· User interface
· Information management
· Memory management
· Communication management
· Network management
A typical GOS environment is depicted in the figure below (Figure 9.2). Part of the
kernel of a GOS is duplicated at all sites. This kernel contains software to control
hardware. Resources like information, memory, etc are managed by software that need
not be replicated.
9.7.1 Migration
The GOS has a pool of resources that it allocates to various processes / tasks at a global
level. Migrations are necessary for optimal use of available resources. Migrations
include:
· Data migration
· Computation migration
· Process migration
Data migration involves movement of data. A program running at a site X wants access to
a file at site Y. Two options exist:
The first option is similar to the approach of a file server whereas the second is similar to
a database server. Software for sending the full file is simple. But the network will be
loaded and in case the file is updated at site X, the entire file has to be again sent back to
Y. If only required portions of a file are sent then network load is less but software to
handle this is complex. Depending on requests for remote data, the GOS may migrate
portion of data from one node to another or may replicate data to improve performance.
This also brings with it the problems of data integrity.
The GOS may sometimes resort to computation migration. If nodes are distributed in a
hierarchical fashion then data migration will need to transfer all files between levels.
Alternatively, if computation migration is followed then a process on one node can
request for execution of another process at a remote site through a RPC. The results of
this computation at remote site are then sent back for use. Here data file transfer is
avoided.
Sometimes a process may be scheduled on a node that does not have the necessary
requirements for the process because of which the process does not complete execution
but is waiting in a blocked state for a long time. Since it was the only processor at the
time of allocation it runs the process. Now that another processor with higher capacity is
free, the GOS should be able to migrate the process to the new processor. There exists a
tradeoff between the gain in performance of the migrated process and the overheads
involved.
· Reducing network load: process execution at a proper node reduces data migration and
hence the load on the network.
The GOS maintains a global list of all resources and allocates them to processes. This
also includes migrated processes . The resource allocation may lead to deadlocks.
Deadlock handling in distributed systems is complex due to difficulties in maintaining an
updated list of global resources. There is also a possibility of a false deadlock alarm. This
may be caused because of incorrect information about resources that in turn may be due
to delay in resource status reaching the global list. Deadlock detection can be centralized
or a distributed function. Deadlocks can also occur in the communication system due to
buffers getting full.
A distributed environment consists of servers and clients. Server is a computer that offers
services of shared resources. Client is a computer that requests for a shared resource
present on the server through a request. A procedure is present on the server to locate and
retrieve data present on a shared device attached to it. This procedure is part of the
operating system running on the server. When a client requests for some data on the
server this procedure on the server operating system is called remotely from the client.
Hence it is called a remote procedure call (RPC).
· Reliable service
· Unreliable service
· Blocking
· Non-blocking
In the blocking scheme, the process on the client that has requested for service from the
server gets blocked until it receives back the data, whereas in the non-blocking scheme,
the process requesting for service continues without waiting.
9.8.3 RPC
Parameters can be passed either by value or by reference. When parameters are passed by
value, the actual parameters are passed. Thus A and B will be actual parameters. If
parameters are passed by reference then the addresses of the actual parameters are passed.
9.8.6 Ports
If a server provides multiple services then normally a port number is associated with each
service. For example, port number 1154 for listing current users, port number 2193 for
opening a file and so on. RPC makes use of these port numbers. This simplifies
communication. Hence a message sent as a RPC to a remote node contains among other
information the port number and parameters for the service. The interface module on the
remote node reads the port number and then executes the appropriate service.
A network has many nodes. Each node has files in its local database. In NOS a user has to
specify the exact location of a file to get it transferred to his / her node. But this is not
required in GOS.
Each node in the network runs its own local operating system and thus has its own file
system. This local file system (LFS) is responsible for allocating space to a file,
maintaining buffers, tables like FAT and so on. Services for file creation, deletion, read
and write are provided by it. It maintains the directory structure and associated files. The
functions of the LFS on a remote file are carried out by the distributed file system (DFS).
It allows the users to see an entire structure of files and directories present in all the nodes
put together as a hierarchy. An important implementation consideration in the design of
DFS is the policy to be used to implement file operations, especially write and update
operations. DFS has to have software to interface with the operating system running on
different nodes. This software should be present on all the nodes. If all nodes run the
same operating system then complexity of DFS is greatly reduced.
UNIX has a feature called RFS that is a DFS for UNIX. SUN has its NFS that is again a
DFS and is part of the SunOS operating system. NetWare-386 can support multiple
machines and multiple networks / distributed file systems at the same time.
9.10 Summary
We have studied what distributed processing is all about. We have seen how
applications / data / control can be distributed. We have also seen the architecture of
typical NOS and its functions. A GOS is necessary for optimal use of memory and
processing power in all computers in a network. We have learnt what a RPC is and how it
is executed. In addition to this an overview of Distributed File Management has also been
discussed.
Self Assessment Questions
4. What is the need for migration? Explain the different types of migration.
4. Call by reference
5. Reliable service
Structure
10.1 Introduction
Objectives
Authentication
Browsing
Invalid Parameters
Line tapping
Rogue Software
Types of Viruses
Infection Methods
Mode of Operation
Virus detection
Virus Removal
Virus Prevention
10.6 Authentication
10.8 Encryption
10.10 Summary
10.12 Answers
10.1 Introduction
Personal computers were designed and intended for individual use. Hence security and
protection features were minimal. No two users could simultaneously use the same
machine. Locking the room physically which housed the computer and its accessories
could easily protect data and stored information. But today hardware costs have reduced
and people have access to a wide variety of computing equipment. With a trend towards
networking, users have access to data and code present locally as well as at remote
locations. The main advantages of networking like data sharing and remote data access
have increased the requirements of security and protection. Security and protection are
the two main features that motivated development of a network operating system
(example Novell NetWare).
· Tapping
· Disclosure
· Amendment
· Fabrication
· Denial
Unauthorized use of service (tapping) and unauthorized disclosure of information
(disclosure) are passive threats whereas unauthorized alteration or deletion of information
(amendment), unauthorized generation of information (fabrication) and denial of service
to authorized users (denial) are active threats. In either tapping or disclosure, information
goes to a third party. In the former, information is accessed by the third party without the
knowledge of the other two parties and in the latter the source willingly / knowingly
discloses it to the third party.
Security is concerned with the ability of the operating system to enforce control over
storage and movement of data in and between the objects that the operating system
supports.
Objectives:
· Computer worms.
A security system can be attacked in many ways. Some of them are discussed below:
10.2.1 Authentication
· Use vendor supplied password usually used by system administrator for purposes of
system maintenance
· Use a terminal to access information that has been logged on by another user and just
left like that.
10.2.2 Browsing
Browsing through system files could get an intruder information necessary to access files
with access controls which are very permissive thus giving the intruder access to
unprotected files / databases.
Passing of invalid parameters of failure to validate them properly can lead to serious
security violations.
If the system administrator has not planned access controls properly, then some users may
have too many privileges and others very few. This amounts to unauthorized disclosure of
information or denial of service.
A variety of software programs exist under this title. Computer virus is very well known
among others. This is a deliberately written program or part of it intended to create
mischief. Such programs vary in terms of complexity or damage they cause. Creators of
this software have a deep knowledge of the operating system and the underlying
hardware. Other rogue software includes Trojan horse, Chameleon, Software bomb,
Worm, etc.
The above mentioned were some common ways in which a security system could be
attacked. Other ways in which a security system can be attacked may be through Trap
doors, Electronic data capture, Lost line, Waste recovery and Covert channels.
10.3 Computer Worms
The invention of computer worms was for a good purpose. Research scientists at XEROX
PARC research center wanted to carry out large computations. They designed small
programs (worms) containing some identified piece of computations that could be carried
out independently and which could spread to other computers. The worm would then
execute on a machine if idle resources were available or else it would hunt the network
for machines with idle resources.
A computer worm does not harm any other program or data but spreads, thereby
consuming large resources like disk storage, transmission capacity, etc. thus denying
them to legal users. A worm usually operates on a network. A node in a network
maintains a list of all other nodes on the network and also a list of machine addresses on
the network. A worm program accesses this list and using it copies itself to all those
address and spreads. This large continuous transfer across the network eats up network
resources like line capacity, disk space, network buffers, tables, etc.
· Worm is a complete program by itself and can execute independently whereas virus
does not operate independently.
Worm consumes only system resources but virus causes direct harm to the system by
corrupting code as well as data.
There are several types of computer viruses. New types get added every now and then.
Some of the common varieties are:
· Boot sector infectors
· Replace: virus code replaces the original executable program either completely or
partially
· Insert: virus code gets inserted into the body of the executable code to carry out some
undesirable actions
· Redirect: The normal flow of a program is changed to execute a virus code that could
exist as an appended portion of an otherwise normal program.
A virus works in a number of ways. The developer of a virus (a very intelligent person)
writes an interesting program such as a game or a utility knowing well the operating
system details on which it is supposed to execute. This program has some embedded
virus code in it. The program is then distributed to users for use through enticing
advertisements and at a low price. Having bought the program at a throwaway price, the
user copies it into his / her machine not aware of the devil which will show up soon. The
virus is now said to be in a nascent state. Curious about the output of the program bought,
the user executes it. Because the virus is embedded in the host program being run, it also
executes and spreads thus causing havoc.
Virus detection programs check for the integrity of binary files by maintaining a
checksum and recalculating it at regular intervals. A mismatch indicates a change in the
executable file, which may be caused due to tampering. Some programs are also available
that are resident in memory and continuously monitor memory and I/O operations.
10.4.5 Virus Removal
A generalized virus removal program is very difficult. Anti-virus codes for removal of
viruses are available. Bit patterns in some virus code are predictable. The anti-virus
programs scan the disk files for such patterns of the known virus and remove them. But
with a number of viruses cropping up every now and then, development and availability
of anti-virus for a particular type is delayed and harm done.
‘Prevention is better than cure’. As the saying goes, there is no good cure available after
infection. One of the safest ways to prevent virus attacks is to use legal copies of
software. Also system needs to be protected against use of unauthorized / unchecked
floppy disks. Frequent backups and running of monitoring programs help detection and
subsequent prevention.
General design principles for protection put forward by Saltzer and Schroeder can be
outlined as under:
· Public design: a security system should not be a secret, an assumption that the
penetrator will know about it is a better assumption.
· Least privileges: every process must be given the least possible privileges necessary for
execution. This assures that domains to be protected are normally small. But an
associated overhead is frequent switching between domains when privileges are updated.
· Explicit demand: access rights to processes should not be granted as default. Access
rights should be explicitly demanded. But this may result in denial of access on some
ground to a legal user.
· Simple design: a simple uniform security system built in layers, as an integral part of
the system is preferred.
· User acceptance: Users should not have to spend a lot of effort to learn how to protect
their files.
· Multiple conditions: wherever possible, the system must be designed to depend on more
than one condition, for example, two passwords / two keys.
10.6 Authentication
Authentication is a process of verifying whether a person is a legal user or not. This can
be by either verification of users logging into a centralized system or authentication of
computers that are to work in a network or a distributed environment.
Password is the most commonly used scheme. It is easy to implement. User name is
associated with a password. This is stored in encrypted form by the system. When the
user logs onto the system, the user has to enter his user name and password against a
prompt. The entered password is then encrypted and matched with the one that is stored
in the file system. A tally will allow the user to login. No external hardware is needed.
But limited protection is provided.
The password is generally not echoed on the screen while being keyed in. Also it is stored
in encrypted form. It cannot be deciphered easily because knowing the algorithm for
deciphering will not suffice as the key is ought to be known for deciphering it.
Choosing a password can be done by the system or by the system administrator or by the
users themselves. A system-selected password is not a good choice as it is difficult to
remember. If the system administrator gives a user a password then more than one person
knows about it. User chosen passwords is practical and popular. Users should choose
passwords that are not easy to guess. Choosing user names, family names, names of
cities, etc are easy to guess.
System resources need to be protected. Resources include both hardware and software.
Different mechanisms for protection are as follows:
Files need to be protected from unauthorized users. The problem of protecting files is
more acute in multi-user systems. Some files may have only read access for some users,
read / write access for some others, and so on. Also a directory of files may not be
accessible to a group of users. For example, student users do not access to any other files
except their own. Like files devices, databases, processes also need protection. All such
items are grouped together as objects. Thus objects are to be protected from subjects who
need access to these objects.
The operating system allows different access rights for different objects. For example,
UNIX has read, write and execute (rwx) rights for owners, groups and others. Possible
access rights are listed below:
· No access
· Execute only
· Read only
· Append only
· Update
· Delete
A hierarchy of access rights is identified. For example, if update right is granted then it is
implied that all rights above update in the hierarchy are granted. This scheme is simple
but creation of a hierarchy of access rights is not easy. It is easy for a process to inherit
access rights from the user who has created it. The system then need maintain a matrix of
access rights for different files for different users.
The operating system defines the concept of a domain. A domain consists of objects and
access rights of these objects. A subject then gets associated with the domains and access
to objects in the domains. A domain is a set of access rights for associated objects and a
system consists of many such domains. A user process always executes in any one of the
domains. Domain switching is also possible. Domains in the form of a matrix is shown in
Figure 10.1.
Since the matrix has many holes, storing the entire matrix is waste of space. Access
control list is one way of storing the matrix. Only information in the columns is stored
and that too only where information is present that is each file has information about
users and their access rights. The best place to maintain this information is the directory
entry for that file.
Capability list is another way of storing the access control matrix. Here information is
stored row wise. The operating system maintains a list of files / devices (objects) that a
user can access along with access rights.
A combination of both access control list and capability list is also possible.
10.8 Encryption
Data before encryption is called plain text and after encryption is called cipher text.
Usually the above operations are performed by hardware.
· Transposition ciphers
· Substitution ciphers
In transposition ciphers the contents of the data are not changed but the order is changed.
For example, a message could be sent in reverse order like:
Railfence cipher is a method that belongs to this class. The method is slow because the
entire message is to be stored and then encrypted. It also requires more storage space
when messages are long.
Substitution ciphers work by sending a set of characters different from the original like:
Ceasar cipher is a popular method of this type. This method is fast and requires less
memory because characters can be changed as they are read and no storage is required.
Variations of this scheme are used for bit streams. Encryption in this case involves adding
a key to every bit stream and decryption is removing the key from the cipher text.
Thus every algorithm has a key. It must ensure restoration. Normally a single piece of
hardware is responsible for both encryption and decryption.
In the conventional encryption scheme two parties A and B agree upon a key. Someone
say A or B or a third party has to decide upon this common key get concurrence from
concerned parties and initiate communication. This is called key distribution. Each pair of
nodes needs a unique key. If there are ‘n’ nodes then there will be nx(n-1)/2 keys. If ‘n’ is
large then the number of keys will also be large. Deciding, conveying and storing these
keys is a mammoth job. Tapping can take place. This is the key distribution problem.
An alternate is the public key encryption. Keys used for encryption and decryption are
not the same. Key K1 is used for encryption and another key K2 is used for decryption. A
message encrypted using K1 can be decrypted only using K2 and not K1. One of the keys
is publicly known. Hence the name public key encryption. Decryption is done using a
private key and hence information cannot leak out. Interchange of keys K1 and K2 is
possible, that is, K2 to encrypt and K1 to decrypt.
Each user has two keys, one public and one private (Figure 10.3). The private key is a
secret but the user publishes the public key to a central key database. The database
maintains public keys of different users.
· B decrypts the received cipher text using its private key and reads the message.
The problem here is that of authentication. B does not know who has sent the message to
it because everybody knows B’s public key. In the conventional encryption method a
single key is used between two parties and hence the receiver knows the sender. But it
suffers from the problem of key distribution. In public key encryption method, for ‘n’
nodes in the network only 2xn keys (1 public and 1 private for each of the nodes) are
required. There need be no agreement. Private key is chosen and a public key is made
known. Key distribution is really not necessary. Key leakage and tapping are minimal.
Protection is ensured but authentication is not provided.
· End-to-end encryption
· Link encryption
If end-to-end encryption is used, the encryption / decryption devices are needed only at
the ends. Data from source to destination moves on the network in encrypted form. In
packet switched networks, data is sent in the form of packets. Each packet has control
information (source address, destination address, checksum, routing information, etc.)
and data. Since routing address is needed for the packet to hop from the source till it
reaches the destination, the control information cannot be encrypted as there is no facility
to decrypt it anywhere in between. Only the data part in a packet can be encrypted. The
system thus becomes vulnerable for tapping.
Link encryption needs more encryption / decryption devices, usually two for each link.
This allows total encryption of a packet and prevents tapping. The method is expensive
and slow.
Message authentication allows users to verify that data received is authentic. Usually the
following attributes of a user need to be authenticated:
· Actual message
· Authentication code
· Encryption
· Digital signatures
In authentication code, a secret key is used to generate a check sum, which is sent along
with the data. The receiver performs the same operation using the same secret key on the
received data and regenerates the check sum. If both of them are same then the receiver
knows the sender since the secret key is known to only both of them.
As discussed earlier, public key encryption provides protection but not authentication. If
we want to authentication without protection, reversal of the keys applied is a solution as
shown below (Figure 10.4).
Figure 10.4: Public key Encryption for authentication without protection
This is based on the concept that public key encryption algorithm works by using either
of the keys to encrypt and the other for decryption. A encrypts the message to be sent to B
using its private key. At the other end B decrypts the received message using A’s public
key which is known to everybody. Thus B knows that A has sent the message. Protection
is not provided as anyone can decrypt the message sent by A.
If both authentication and protection are needed then a specific sequence of public and
private keys is used as show below (Figure 10.5).
The two keys are used as shown. At points 2 and 4 the cipher text is the same. Similarly
at points 1 and 5 the text is the same. Authentication is possible because between 4 and 5
decryption is done by A’s public key and is possible only because A has encrypted it with
its private key. Protection is also guaranteed because from point 3 onwards only B can
decrypt with its private key. This is how digital signatures work.
Figure 10.5: Public key Encryption for both authentication and protection
10.10 Summary
This unit looks into an important part of any operating system – security and protection.
These were trivial matters in earlier systems since computers were centralized systems
accessed only by knowledgeable users. With advances and use of networking, security
and protection requirements have increased. Different ways in which system could be
attacked are understood. Authentication using passwords is studied. Protection by looking
at objects and users in domains accessing objects with different access rights is analyzed.
Encryption as an important tool in protection, security and authentication has been
studied.
5. In transposition ciphers the contents of the data are not changed but
_________________.
5. What is encryption? What are the different ways in which a message can be encrypted?
1. Passive threats.
2. Authentication.
4. Length of a password
5. Refer section10.8
6. Refer section 10.9