Professional Documents
Culture Documents
Operating System
MCA
Poonam Sharma
Deptt. of IT
Biyani Girls College, Jaipur
2
Published by :
Think Tanks
Biyani Group of Colleges
Edition : 2012
While every effort is taken to avoid errors or omissions in this Publication, any mistake or
omission that may have crept in is not intentional. It may be taken note of that neither the
publisher nor the author will be responsible for any damage or loss of any kind arising to
anyone in any manner on account of such errors and omissions.
Preface
I am glad to present this book, especially designed to serve the needs of the
students. The book has been written keeping in mind the general weakness in
understanding the fundamental concepts of the topics. The book is self-explanatory and
adopts the Teach Yourself style. It is based on question-answer pattern. The language
of book is quite easy and understandable based on scientific approach.
Any further improvement in the contents of the book by making corrections,
omission and inclusion is keen to be achieved based on suggestions from the readers
for which the author shall be obliged.
I acknowledge special thanks to Mr. Rajeev Biyani, Chairman & Dr. Sanjay Biyani,
Director (Acad.) Biyani Group of Colleges, who are the backbones and main concept
provider and also have been constant source of motivation throughout this endeavour.
They played an active role in coordinating the various stages of this endeavour and
spearheaded the publishing work.
I look forward to receiving valuable suggestions from professors of various
educational institutions, other faculty members and students for improvement of the
quality of the book. The reader may feel free to send in their comments and suggestions
to the under mentioned address.
Author
4
Syllabus
M.C.A. Sem.-II
OPERATING SYSTEM (MCA-204)
Introduction: Definition and types of operating systems, Batch Systems, multi
programming, timesharing parallel, distributed and real-time systems, Operating
system structure, Operating system components and services, System calls, system
programs, Virtual machines.
Process Management: Process concept, Process scheduling, Cooperating processes,
Threads, Inter-process communication, CPU scheduling criteria, Scheduling algorithms,
Multiple processor scheduling, Real-time scheduling and Algorithm evaluation.
Process Synchronization and Deadlocks: The Critical-Section problem, synchronization
hardware, Semaphores, Classical problems of synchronization, Critical regions,
Monitors, Deadlocks-System model, Characterization, Deadlock prevention, Avoidance
and Detection, Recovery from deadlock, Combined approach to deadlock handling.
Storage management: Memory Management-Logical and Physical Address Space,
Swapping, Contiguous Allocation, Paging, Segmentation with paging, Virtual Memory,
Demand paging and its performance, Page replacement algorithms, Allocation of
frames, Thrashing, Page Size and other considerations, Demand segmentation,
File systems, secondary Storage Structure, File concept, access methods, directory
implementation, Efficiency and performance, recovery, Disk structure, Disk scheduling
methods, Disk management, Recovery, Disk structure, disk scheduling methods, Disk
management, Swap-Space management, Disk reliability.
Protection and Security-Goals of protection, Domain of protection, Access matrix,
Implementation of access Matrix, Revocation of Access Rights, language based
protection, The Security problem, Authentication, One Time passwords, Program
threats, System threats, Threat Monitoring, Encryption.
Case study: Windows NT-Design principles, System components, Environmental,
Environmental subsystems, File system, Networking and program interface.
Subsystems, File system, Networking and program interface.
Operating System 5
Content
S.No. Name of Topic
1. Introduction to Operating System
1.1 Definition of Operating system
1.2 Types of operating system
1.3 Operating system structure
1.4 Operating system components and services
1.5 System calls, system programs
1.6 Virtual machines.
2. Process Management
2.1 Process concept, Process
2.2 Cooperating processes
2.3 Threads
2.4 Inter-process communication
2.5 scheduling CPU scheduling criteria
2.6 Scheduling algorithms & Algorithm evaluation.
2.7 Multiple processor scheduling
2.8 Real-time scheduling
Chapter- 1
Introduction to Operating system
Q1 What do you mean by Operating System?
Ans: Operating System:- An operating system is a System software that acts as an
intermediary between a user of a computer and the computer hardware. The
purpose of an operating system is to provide an environment in which a user can
execute program. An operating system is an important part of almost every
computer system. It is basically a control program that controls the execution of
user programs to prevent errors and improper use of the computer. A computer
system can be divided roughly into four components: the hardware,
the operating system, the application programs, and the users
In this execution environment, the CPU is often idle, because the speeds of
the mechanical I/O devices are intrinsically slower than are those of electronic
devices. The introduction of disk technology allowed the operating system to
keep all jobs on a disk, rather than in a serial card reader. With direct access to
several jobs, the operating system could perform job scheduling, to use resources
and perform tasks efficiently.
2- Multiprogramming Systems:- In this type of Operating systems, more than one
program will reside in to main memory. The operating system picks and begins
to execute one of the jobs in the memory. Eventually, the job may have to wait
for some task, the operating system simply switches to and executes another job.
When the first job finishes waiting and gets the CPU back. As long as there is
always some job to execute, the CPU will never be idle.
3 Time Sharing Systems:- A time-shared operating system allows the many users to
share the computer simultaneously. A time-shared operating system uses CPU
10
4 Real Time Operating System:- Real time Operating systems is a special purpose
operating system, used when there are rigid time requirements on the operation
of a processor or the flow of data. Thus, it is often used as a control device in a
dedicated application. Sensors bring data to the computer. The computer must
analyze the data and possibly adjust controls to modify the sensor inputs.
Systems that control scientific experiments, medical imaging systems,
Industrial control systems, and certain display systems are real-time systems.
5 Parallel System:-. Such systems have more than one processor in close
communication, sharing the computer bus, the clock, and sometimes memory
and peripheral devices. Hence parallel system is also called tightly coupled
systems. There is a large amount of data to be shared by different processors.
These systems have three main advantages:- Increased throughput, Economy of
scale and Increased reliability.
Program execution: The system must be able to load a program into memory and
to run that program. The program must be able to end its execution, either
normally or abnormally
I/O operations: A running program may require I/O. This I/O may involve a
file or an I/O device. For specific devices, special functions may be desired. For
efficiency and protection, operating system must provide a means to do I/O.
File-system manipulation: programs need to read and write files. Programs also
need to create and delete files by name.
Communications: In many situations one process needs to exchange information
with another process. Communications may be implemented via shared
memory, or by the technique of message passing, in which packets of
information are moved between processes by the operating system.
In addition, another set of operating-system functions exists not for helping the
user, but for ensuring the efficient operation of the system itself. Systems with
multiple users can gain efficiency by sharing the computer resources among the
users. It includes: Resource allocation, accounting, Protection etc.
Ans System Calls:- System calls provide the interface between a process and the
operating system. These calls are generally available as assembly-language
instructions. Certain systems allow system calls to be made directly from a
higher level language program, in which case the calls normally resemble
predefined function or subroutine calls. They may generate a call to a special
run-time routine that makes the system call, or the system call may be generated
directly
File management: These programs create, delete, copy, rename, print, list, and
generally manipulate files and directories.
Status information: Some programs simply ask the system for the date, time,
amount of available memory or disk space, number of users, or similar status
information.
File modification: Several text editors may be available to create and modify the
content of files stored on disk or tape.
Programming-language support: Compilers, assemblers, and interpreters for
common programming languages are often provided to the user with the
operating system.
Most operating systems are supplied with programs that solve common
problems, or perform common operations. Such programs include web browsers,
word processors, database systems, compiler etc. These programs are known as
system utilities or application programs.
Chapter-2
Process Management
Q1 Write the definition of process.
Ans Process Definition:- In general, a process is a program in execution. The
execution of a process is progress in a sequential fashion. Thus a process is an
active entity with a program counter, specifying the next instruction to be
executed and a set of associated resources. A program is a passive entity, such as
the contents of a file stored on disk, whereas a process
is an active entity, with a program counter specifying the next instruction to
execute and a set of associated resources. A process is more than the program
code; it also includes the current activity, as represented by the value of the
program counter and the contents of the processor's registers. In addition, a
process generally includes the process stack, which contains temporary data and
a data section, which contains global variables.
4- Waiting: The process is waiting for some event to occur (such as an I/O
completion)
Q5 What is the difference between CPU bound and I/O bound processes?
Ans I/O bound processes:-An I/O bound process is one that spends more of its time
to doing I/O then it spends on doing computation.
CPU bound Processes:- CPU bound processes needs very little I/O, but requires
heavy computation. These processes requires
Operating System 17
For a balanced system scheduler should select a good process mix of I/O-bound
and CPU-bound processes. If all processes are I/O bound, the ready queue will
almost always be empty, and the short-term scheduler will have little to do.
If all processes are CPU bound, the I/O waiting queue will almost always be
empty, devices will go unused, and again the system will be unbalanced. The
system with the best performance will have a combination of CPU-bound and
I/O-bound processes.
2- Device Queue:- This queue contain a list processes waiting for I/O devices.
Each device has its own device queue.
18
Queuing-diagram
A new process is initially put in the ready queue. It waits in the ready queue
until it is selected for execution (or dispatched). Once the process is assigned to
the CPU and is executing, one of several events could occur:
The process could issue an I/O request, and then be placed in an I/O queue.
The process could create a new sub-process and wait for its termination.
The process could be removed forcibly from the CPU, as a result of an
interrupt, and be put back in the ready queue.
Long Term Schedulers:- This scheduler determines which job will be submitted
for immediate processing. It selects from the job pool and loads them into
memory. The long-term scheduler, executes much less frequently. The long-term
scheduler may need to be invoked only when a process leaves the system.
Because of the longer interval between executions, the long-term scheduler can
afford to take more time to select a process for execution. The long-term
scheduler controls the degree of multiprogramming-the number of processes in
memory.
Q8 What are the different criteria for measuring the performance of scheduling
mechanism?
Ans Performance criteria for scheduling mechanism:-
The various criteria for measuring the scheduler performance are
1- CPU Utilization:- We want to keep the CPU as busy as possible. CPU
utilization may range from 0 to 100 percent.
4- Waiting time:- Waiting time is the sum of the periods spent waiting in the
ready queue.
response time, is the amount of time it takes to start responding, but not the time
that it takes to output that response.
For example:- Consider the following set of processes that arrive at time 0, with
the length of the CPU-burst time given in milliseconds:
Process Burst Time
PI 24
P2 3
Operating System 21
P3 3
If the processes arrive in the order PI, P2, P3, and are served in FCFS order,
The waiting time is 0 milliseconds for process PI, 24 milliseconds for process P2,
and 27 milliseconds for process P3. Thus, the average waiting time is (0 + 24 +
27)/3 = 17 milliseconds.
2- Shortest-Job First (SJF) Scheduling:- In this scheme, job requiring the minimal
CPU time is selected first for CPU allocation.
For example:- Consider the following set of processes that arrive at time 0, with
the length of the CPU-burst time given in milliseconds:
Process Burst Time
PI 24
P2 3
P3 3
If the processes arrive in the order P2, P3, P1 according to minimum CPU burst
time
4- Deadline Scheduling:- With this scheduling algorithm the process with earliest
deadline is given the highest priority for execution.
2- Two Queue scheduling:- In this approach, the processes are classified into two
different groups. One queue is allocated to CPU bound processes and other is
allocated to I/O bound processes.
Chapter-3
Process synchronization and deadlocks
Q1 Explain the concept of Synchronization.
Ans Synchronization:- The concept of synchronization is concerned with co-
operating processes that share some resources. Co-operating processes must
synchronize with each other when they are used shared resources. Thus we can
view the synchronization as a set of constraints on the ordering of events.
2. Hold and wait : There must exist a process that is holding at least one resource
and is waiting to acquire additional resources that are currently being held by
other processes.
3. No preemption : Resources cannot be preempted; that is, a resource can be
released only voluntarily by the process holding it, after that process, has
completed its task.
4. Circular wait: There must exist a set {P0, P1, ..., P2} of waiting processes such that
P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is
held by P2, ., Pn-1 is waiting for a resource that is held by Pn, and Pn is waiting
for a resource that is held by P0.
No Preemption
If a process that is holding some resources requests another resource that cannot
be immediately allocated to it, then all resources currently being held are
26
released implicitly. Then the preempted resources are added to the list of
resources for which the process is waiting.
Circular Wait
Circular-wait condition never holds is to impose a total ordering of all resource
types, and to require that each process requests resources in an increasing order
of enumeration.
Safe State
A state is safe if the system can allocate resources to each process (up to its
maximum) in some order and still avoid a deadlock. More formally, a system is
in a safe state only if there exists a safe sequence. If no such sequence exists, then
the system state is said to be unsafe.
Banker's Algorithm
This resource-allocation graph algorithm is applicable to a resource-allocation
system with multiple instances of each resource type. This algorithm is
commonly known as the banker's algorithm.
Chapter-4
Primary Memory Management
Q1 What is difference between logical and physical addresses?
Ans Logical versus Physical Address Space:- An address generated by the CPU is
commonly referred to as a logical address, whereas an address seen by the
memory unit is commonly referred to as a physical address. The set of all logical
addresses generated by a program is referred to as a logical address space; the set
of all physical addresses corresponding to these logical addresses is referred to as
a physical address space. The user program deals with logical addresses. The
memory-mapping hardware converts logical addresses into physical addressed
again Instead of swapping in a whole process; the pager brings only those
necessary pages into memory. Thus, it avoids reading into memory pages that
will not be used in anyway, decreasing the swap time and the amount of
physical memory needed.
Chapter-5
Secondary storage Management
Q1 Explain the file system in brief.
Ans File system :- A file is a named collection of related information that is recorded
on secondary storage. It is the smallest allotment of logical secondary storage.
Commonly, files represent programs and data . In general, a file is a sequence of
bits, bytes, lines, or records. A file has a certain defined structure, which depends
on its type
A file is typically consist of these: Name, Identifier, Type, Location, Size,
Protection, Time, date, and user identification. The information about all files is
kept in the directory structure. The operating system can provide system calls to
create, write, read, reposition, delete, and truncate files.
Q2- Define the strategies of contiguous, linked and indexed allocation in file
system.
Ans (i) Contiguous Allocation The contiguous allocation method requires each file to
occupy a set of contiguous blocks on the disk. Disk addresses define a linear
ordering on the disk. The directory entry for each file indicates the address of the
starting block and the length of the area allocate for this file. Accessing a file that
has been allocated contiguously is easy.
(ii) Linked Allocation
With link allocation, each file is a linked list disk blocks; the disk blocks may be
scattered anywhere on the disk and any free block on the free-space list can be
used to satisfy a request ,there is no need to declare the size of a file when that
file is created. A file can continue to grow as long as there are free blocks.
(iii) Indexed Allocation
The problem with Linked allocation is that, the pointers to the blocks are
scattered with the blocks themselves all over the disk and need to be retrieved in
order, while in Indexed allocation all the pointers bring together into one
location: the index block. These types of allocation supports direct access.
owner of the file etc. the directory is itself a file, owned by the operating system
and accessible by various file management routines.
2- General Graph Directory: - One problem with using an acyclic graph structure
is ensuring that there is no cycle. However to avoid traversing shared sectors
of an acyclic graph twice, we can allow cycles to exist. If cycles are allowed to
exist in the directory, we generally, want to avoid searching any component
twice, for reason of correctness and performance.
Operating System 33
Chapter-6
Protection and Security
Q1 Define various security threats in context of computer system.
Ans Security Threats:- The major security threats perceived by user and providers of
computer-based systems are-
1- Unauthorized disclosure of information
2- Unauthorized alteration or destruction of information
3- Unauthorized use of service
4- Denial of service to legitimate users.