0% found this document useful (0 votes)
4 views82 pages

Operating System Tutorial

An operating system (OS) is essential software that manages computer hardware and provides services for programs, acting as an intermediary between users and hardware. It evolved from early computing methods to modern systems that support multiple users and tasks simultaneously, including batch processing, time-sharing, and real-time operations. Key functions of an OS include memory management, processor management, device management, and file management, with various types of operating systems designed for specific applications and environments.

Uploaded by

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

Operating System Tutorial

An operating system (OS) is essential software that manages computer hardware and provides services for programs, acting as an intermediary between users and hardware. It evolved from early computing methods to modern systems that support multiple users and tasks simultaneously, including batch processing, time-sharing, and real-time operations. Key functions of an OS include memory management, processor management, device management, and file management, with various types of operating systems designed for specific applications and environments.

Uploaded by

hapevaw398
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

OPERATING SYSTEM

DIPLOMA IN ICT

MODULE I

KNEC SYSTEM
Operating System Tutorial
An operating system (OS) is a collection of software that manages computer hardware resources
and provides common services for computer programs. The operating system is a vital
component of the system software in a computer system.

Operating System - Overview


An operating System (OS) is an intermediary between users and computer hardware. It provides
users an environment in which a user can execute programs conveniently and efficiently.
In technical terms, It is a software which manages hardware. An operating System controls the
allocation of resources and services such as memory, processors, devices and information.
Definition
An operating system is a program that acts as an interface between the user and the computer
hardware and controls the execution of all kinds of programs.

Nature and History of Operating Systems for Computers


An operating system is a program that runs on a computer to simplify the use of the computer for the user.
The operating system manages the use of peripheral devices such as printers, monitors and keyboards. In
addition the operating system will run other programs and display the results. In order to carry out these
functions the operating system has to require a systematic structure for the inputs and outputs; there is a
definite structure to files and there is a systematic way in which the files are stored on the data storage
devices. Without an operating system a computer is largely an unresponsive hunk of metal and wires.
Although now the concept of an operating system appears to be a natural and obvious one, operating
systems evolved over a considerable period of time. The first electronic computers were "hardwired" to
carryout systematic computations. Initially the computations were for ballistics table. The user would
wire direct connections between the various components of the computer through a plug board. When the
computations were finished the next user would have to pull out the wires and rewire for the next set of
computations. This was monumentally cumbersome by today's standard but a marvelous advance in speed
and accuracy over hand computations with pencil and paper.
The first technological breakthrough came with the creation of internally stored programs. This involved
memory with memory locations with addresses. A program was then the loading of information in a set of
memory locations. The information at a memory address consisted of two parts. One part was the code for
the operations which the computer could perform such as adding numbers together. The second part was
the address of the next memory location in the sequence. Thus the computer would retrieve the contents
of one memory location which would tell it which operations to carryout and which memory address to
go to for instructions for the next step in the computations. The idea for this internally stored program is
generally associated with the mathematician, John von Neumann.
When computers became more technically complex the users could not have direct access to the
equipment. Instead it was necessary for the users to record their programs on punched cards or punced
tape which would be given to professional computer technicians to run on the computer. During this stage
the computers filled a good sized room and required air conditioning to control temperature and humidity.
The computer programs had to be run in batches and there had to be seperate programs to handle the
reading in of data and the output of the results. One job had to be completed before the next could run. It
was efficient to arrange for the reading-in of programs to memory storage while another program was
running because the computation time on the computer was often far quicker than the operation of
reading in the information for computation.
Sometimes one program would be paused while waiting for the completion of some peripheral operation
such as printing. Computer systems designers created the systems programs to make it possible to run
another program for a short period while the first program's computation was paused. And of course the
second program could also be paused so provision was made to bring in a new program when the other
programs were paused. The computer would have to go back to previously initiated programs once they
were ready to compute again. This was called multiprogramming and the specific operation was called
spooling, which was the acronym for simutaneouspripheral operation on line.
The next step was allow several users to share the use of the computer simultaneously. The computer
would run one user's job for a prescribed short period of time and then move on to the next user's job.
This was called time-sharing. It allowed for allocating the period of computation on the basis of the
priority rankings of the various job.
With time-sharing came the possiblity of interactivity. With the users providing input from terminals one
user's might be paused for a relatively long time while waiting for input from the user. The computer were
so fast that each user might not perceive any delay from the computer switching among the other users'
programs.
Time sharing was an enormous improvement for computer users. Under the previous system of batch
operation a user might have to wait days to get the results back from a job. The result might be the
statement that the program did not run because of a programming error or an error in the data. These were
often errors that could be corrected during an interactive time sharing session.
In the late 1960's M.I.T. had a time sharing operating system called MULTICS, the name indicating it
was a multiple user systems. Ken Thompson was working at Bell Labs in New Jersey and was given the
use of a PDP-7 minicomputer. He decided to create an operating system for the minicomputer for the
convenience it provided even though there would be only one user. Initially he called this operating
system UNICS in analogy with MULTICS but later changed the spelling to UNIX. At the same time
Dennis Ritchie was involved in the creation of the programming language "C," so named because it was
modelled on the programming language developed in Britain called "B." The collaboration between Ken
Thompson and Dennis Ritchie has been quite fruitful over the years. UNIX and C have also been closely
linked.
UNIX was an important innovation in computer. It is awkward but the computer professionals were
perfectly willing to tolerate its difficulties in order to get the power it gave them access to. UNIX's
shortcomings were not considered notable at the time. The concept of user-friendly software came a
decade later. UNIX users were more concerned that something could be achieved at all rather than
whether it required use of non-mnemonic commands.
The use of UNIX spread around the country and initially Bell Labs gave it away free. Later Bell Labs
realized that UNIX had commercial potential and arranged for the marketing of it.
With the concept of operating system widely popularized it was standard practice to develop an operating
system for each new line of computers. About this time the personal computer was developed.
Gary Kildall of the Naval Postgraduate School in Monterey, California acquired one of the early personal
computers and he immediately proceded to develop an operating system for it. He called the operationg
system CP/M, for Control Processor Monitor. It was the first operating system for a personal computer.
The story of Gary Kildall and IBM and Bill Gates and the Disk Operating System (DOS) is told
elsewhere.
At Apple Computer the personal computer was undergoing major evolution. One element of that
evolution was the creation of a new operating system which utilized graphic input from a new peripheral,
the mouse. It was the most user-friendly of the systems up to that date.
Microsoft rose to fame and power on the basis of the Disk Operating System, one of the most dramatic
business coups of the twentieth century. But while DOS was great it lacked the ease of use of the Apple
system so Microsoft launched a project to create an operating to achieve the ease of use of Apple's
operating system. The result was Windows. The first versions were not spectacularly successful
technically and commercially but Microsoft continued to develop Windows until it became virtually the
universal operating system for personal computers. This was in part due to the technically capabilities and
ease of use of Windows but it was also due to the marketing practices of Microsoft which resulted in
every personal computer coming with Windows so the acquisition of any other operating system would
superfluous and costly.
There has been some competition for Windows. A college student in Finland, Linus Thorvald, developed
a version of UNIX as an operating system for personal computers. This operating system is called LINUX
after Thorvald's first name. Linus Thorvald, in addition to writing the code for components of LINUX
himself, organized a community effort among programmers to get the code created and tested. LINUX
was made free to the general public.
Sun Microsystems in the Silicon Valley has also developed the Solaris operating system, which competes
with Windows among computer professionals, particularly the one using the work station computers
manufactured by Sun Microsystems.

Following are some of important functions of an operating System.


 Memory Management
 Processor Management
 Device Management
 File Management
 Security
 Control over system performance
 Job accounting
 Error detecting aids
 Coordination between other software and users
Memory Management
Memory management refers to management of Primary Memory or Main Memory. Main
memory is a large array of words or bytes where each word or byte has its own address.
Main memory provides a fast storage that can be access directly by the CPU. So for a program to
be executed, it must in the main memory. Operating System does the following activities for
memory management.
 Keeps tracks of primary memory i.e. what part of it are in use by whom, what part are not
in use.
 In multiprogramming, OS decides which process will get memory when and how much.
 Allocates the memory when the process requests it to do so.
 De-allocates the memory when the process no longer needs it or has been terminated.
Processor Management
In multiprogramming environment, OS decides which process gets the processor when and how
much time. This function is called process scheduling. Operating System does the following
activities for processor management.
 Keeps tracks of processor and status of process. Program responsible for this task is
known as traffic controller.
 Allocates the processor(CPU) to a process.
 De-allocates processor when processor is no longer required.
Device Management
OS manages device communication via their respective drivers. Operating System does the
following activities for device management.
 Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
 Decides which process gets the device when and for how much time.
 Allocates the device in the efficient way.
 De-allocates devices.
File Management
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions. Operating System does the following activities
for file management.
 Keeps track of information, location, uses, status etc. The collective facilities are often
known as file system.
 Decides who gets the resources.
 Allocates the resources.
 De-allocates the resources.
Other Important Activities
Following are some of the important activities that Operating System does.
 Security -- By means of password and similar other techniques, preventing unauthorized
access to programs and data.
 Control over system performance -- Recording delays between request for a service
and response from the system.
 Job accounting -- Keeping track of time and resources used by various jobs and users.
 Error detecting aids -- Production of dumps, traces, error messages and other debugging
and error detecting aids.
 Coordination between other softwares and users -- Coordination and assignment of
compilers, interpreters, assemblers and other software to the various users of the
computer systems.

Types of Operating System


Operating systems are there from the very first computer generation. Operating systems keep
evolving over the period of time. Following are few of the important types of operating system
which are most commonly used.
Batch operating system
The users of batch operating system do not interact with the computer directly. Each user
prepares his job on an off-line device like punch cards and submits it to the computer operator.
To speed up processing, jobs with similar needs are batched together and run as a group. Thus,
the programmers left their programs with the operator. The operator then sorts programs into
batches with similar requirements.
The problems with Batch Systems are following.
 Lack of interaction between the user and job.
 CPU is often idle, because the speeds of the mechanical I/O devices is slower than CPU.
 Difficult to provide the desired priority.
Time-sharing operating systems
Time sharing is a technique which enables many people, located at various terminals, to use a
particular computer system at the same time. Time-sharing or multitasking is a logical extension
of multiprogramming. Processor's time which is shared among multiple users simultaneously is
termed as time-sharing. The main difference between Multiprogrammed Batch Systems and
Time-Sharing Systems is that in case of Multiprogrammed batch systems, objective is to
maximize processor use, whereas in Time-Sharing Systems objective is to minimize response
time.
Multiple jobs are executed by the CPU by switching between them, but the switches occur so
frequently. Thus, the user can receives an immediate response. For example, in a transaction
processing, processor execute each user program in a short burst or quantum of computation.
That is if n users are present, each user can get time quantum. When the user submits the
command, the response time is in few seconds at most.
Operating system uses CPU scheduling and multiprogramming to provide each user with a small
portion of a time. Computer systems that were designed primarily as batch systems have been
modified to time-sharing systems.
Advantages of Timesharing operating systems are following
 Provide advantage of quick response.
 Avoids duplication of software.
 Reduces CPU idle time.
Disadvantages of Timesharing operating systems are following.
 Problem of reliability.
 Question of security and integrity of user programs and data.
 Problem of data communication.
Distributed operating System
Distributed systems use multiple central processors to serve multiple real time application and
multiple users. Data processing jobs are distributed among the processors accordingly to which
one can perform each job most efficiently.
The processors communicate with one another through various communication lines (such as
high-speed buses or telephone lines). These are referred as loosely coupled systems or distributed
systems. Processors in a distributed system may vary in size and function. These processors are
referred as sites, nodes, computers and so on.
The advantages of distributed systems are following.
 With resource sharing facility user at one site may be able to use the resources available
at another.
 Speedup the exchange of data with one another via electronic mail.
 If one site fails in a distributed system, the remaining sites can potentially continue
operating.
 Better service to the customers.
 Reduction of the load on the host computer.
 Reduction of delays in data processing.
Network operating System
Network Operating System runs on a server and and provides server the capability to manage
data, users, groups, security, applications, and other networking functions. The primary purpose
of the network operating system is to allow shared file and printer access among multiple
computers in a network, typically a local area network (LAN), a private network or to other
networks. Examples of network operating systems are Microsoft Windows Server 2003,
Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD.
The advantages of network operating systems are following.
 Centralized servers are highly stable.
 Security is server managed.
 Upgrades to new technologies and hardwares can be easily integrated into the system.
 Remote access to servers is possible from different locations and types of systems.
The disadvantages of network operating systems are following.
 High cost of buying and running a server.
 Dependency on a central location for most operations.
 Regular maintenance and updates are required.
Real Time operating System
Real time system is defines as a data processing system in which the time interval required to
process and respond to inputs is so small that it controls the environment. Real time processing is
always on line whereas on line system need not be real time. The time taken by the system to
respond to an input and display of required updated information is termed as response time. So in
this method response time is very less as compared to the online processing.
Real-time systems are used when there are rigid time requirements on the operation of a
processor or the flow of data and real-time systems can be used as a control device in a dedicated
application. Real-time operating system has well-defined, fixed time constraints otherwise
system will [Link] example Scientific experiments, medical imaging systems, industrial control
systems, weapon systems, robots, and home-applicance controllers, Air traffic control system
etc.
There are two types of real-time operating systems.
Hard real-time systems
Hard real-time systems guarantee that critical tasks complete on time. In hard real-time systems
secondary storage is limited or missing with data stored in ROM. In these systems virtual
memory is almost never found.
Soft real-time systems
Soft real time systems are less restrictive. Critical real-time task gets priority over other tasks and
retains the priority until it completes. Soft real-time systems have limited utility than hard real-
time [Link] example, Multimedia, virtual reality, Advanced Scientific Projects like
undersea exploration and planetary rovers etc.

Operating System - Services


An Operating System provides services to both the users and to the programs.
It provides programs, an environment to execute.

 It provides users, services to execute the programs in a convenient manner.
Following are few common services provided by operating systems.
 Program execution
 I/O operations
 File System manipulation
 Communication
 Error Detection
 Resource Allocation
 Protection
Program execution
Operating system handles many kinds of activities from user programs to system programs like
printer spooler, name servers, file server etc. Each of these activities is encapsulated as a process.
A process includes the complete execution context (code to execute, data to manipulate,
registers, OS resources in use). Following are the major activities of an operating system with
respect to program management.
 Loads a program into memory.
 Executes the program.
 Handles program's execution.
 Provides a mechanism for process synchronization.
 Provides a mechanism for process communication.
 Provides a mechanism for deadlock handling.
I/O Operation
I/O subsystem comprised of I/O devices and their corresponding driver software. Drivers hides
the peculiarities of specific hardware devices from the user as the device driver knows the
peculiarities of the specific device.
Operating System manages the communication between user and device drivers. Following are
the major activities of an operating system with respect to I/O Operation.
 I/O operation means read or write operation with any file or any specific I/O device.
 Program may require any I/O device while running.
 Operating system provides the access to the required I/O device when required.
File system manipulation
A file represents a collection of related information. Computer can store files on the disk
(secondary storage), for long term storage purpose. Few examples of storage media are magnetic
tape, magnetic disk and optical disk drives like CD, DVD. Each of these media has its own
properties like speed, capacity, data transfer rate and data access methods.
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions. Following are the major activities of an
operating system with respect to file management.
 Program needs to read a file or write a file.
 The operating system gives the permission to the program for operation on file.
 Permission varies from read-only, read-write, denied and so on.
 Operating System provides an interface to the user to create/delete files.
 Operating System provides an interface to the user to create/delete directories.
 Operating System provides an interface to create the backup of file system.
Communication (inter process)
In case of distributed systems which are a collection of processors that do not share memory,
peripheral devices, or a clock, operating system manages communications between processes.
Multiple processes communicate with one another through communication lines in the network.
OS handles routing and connection strategies, and the problems of contention and security.
Following are the major activities of an operating system with respect to communication.
 Two processes often require data to be transferred between them.
 The both processes can be on the one computer or on different computer but are
connected through computer network.
 Communication may be implemented by two methods either by Shared Memory or by
Message Passing.
Error handling
Error can occur anytime and anywhere. Error may occur in CPU, in I/O devices or in the
memory hardware. Following are the major activities of an operating system with respect to error
handling.
 OS constantly remains aware of possible errors.
 OS takes the appropriate action to ensure correct and consistent computing.
Resource Management
In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles
and files storage are to be allocated to each user or job. Following are the major activities of an
operating system with respect to resource management.
 OS manages all kind of resources using schedulers.
 CPU scheduling algorithms are used for better utilization of CPU.
Protection
Considering a computer system having multiple users the concurrent execution of multiple
processes, then the various processes must be protected from each another's activities.
Protection refers to a mechanism or a way to control the access of programs, processes, or users
to the resources defined by a computer systems. Following are the major activities of an
operating system with respect to protection.
 OS ensures that all access to system resources is controlled.
 OS ensures that external I/O devices are protected from invalid access attempts.
 OS provides authentication feature for each user by means of a password.
Operating System - Properties
Following are few of very important tasks that Operating System handles
Batch processing
Batch processing is a technique in which Operating System collects one programs and data
together in a batch before processing starts. Operating system does the following activities
related to batch processing.
 OS defines a job which has predefined sequence of commands, programs and data as a
single unit.
 OS keeps a number jobs in memory and executes them without any manual information.
 Jobs are processed in the order of submission i.e first come first served fashion.
 When a job completes its execution, its memory is released and the output for the job gets
copied into an output spool for later printing or processing.

Advantages
 Batch processing takes much of the work of the operator to the computer.
 Increased performance as a new job get started as soon as the previous job finished
without any manual intervention.
Disadvantages
 Difficult to debug program.
 A job could enter an infinite loop.
 Due to lack of protection scheme, one batch job can affect pending jobs.
Multitasking
Multitasking refers to term where multiple jobs are executed by the CPU simultaneously by
switching between them. Switches occur so frequently that the users may interact with each
program while it is running. Operating system does the following activities related to
multitasking.
 The user gives instructions to the operating system or to a program directly, and receives
an immediate response.
 Operating System handles multitasking in the way that it can handle multiple operations /
executes multiple programs at a time.
 Multitasking Operating Systems are also known as Time-sharing systems.
 These Operating Systems were developed to provide interactive use of a computer system
at a reasonable cost.
 A time-shared operating system uses concept of CPU scheduling and multiprogramming
to provide each user with a small portion of a time-shared CPU.
 Each user has at least one separate program in memory.

 A program that is loaded into memory and is executing is commonly referred to as a


process.
 When a process executes, it typically executes for only a very short time before it either
finishes or needs to perform I/O.
 Since interactive I/O typically runs at people speeds, it may take a long time to
completed. During this time a CPU can be utilized by another process.
 Operating system allows the users to share the computer simultaneously. Since each
action or command in a time-shared system tends to be short, only a little CPU time is
needed for each user.
 As the system switches CPU rapidly from one user/program to the next, each user is
given the impression that he/she has his/her own CPU, whereas actually one CPU is
being shared among many users.
Multiprogramming
When two or more programs are residing in memory at the same time, then sharing the processor
is referred to the multiprogramming. Multiprogramming assumes a single shared processor.
Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has one
to execute.
Following figure shows the memory layout for a multiprogramming system.
Operating system does the following activities related to multiprogramming.
 The operating system keeps several jobs in memory at a time.
 This set of jobs is a subset of the jobs kept in the job pool.
 The operating system picks and begins to execute one of the jobs in the memory.
 Multiprogramming operating system monitors the state of all active programs and system
resources using memory management programs to ensures that the CPU is never idle
unless there are no jobs
Advantages
 High and efficient CPU utilization.
 User feels that many programs are allotted CPU almost simultaneously.
Disadvantages
 CPU scheduling is required.
 To accommodate many jobs in memory, memory management is required.
Interactivity
Interactivity refers that a User is capable to interact with computer system. Operating system
does the following activities related to interactivity.
 OS provides user an interface to interact with system.
 OS managers input devices to take inputs from the user. For example, keyboard.
 OS manages output devices to show outputs to the user. For example, Monitor.
 OS Response time needs to be short since the user submits and waits for the result.
Real Time System
Real time systems represents are usually dedicated, embedded systems. Operating system does
the following activities related to real time system activity.
 In such systems, Operating Systems typically read from and react to sensor data.
 The Operating system must guarantee response to events within fixed periods of time to
ensure correct performance.
Distributed Environment
Distributed environment refers to multiple independent CPUs or processors in a computer
system. Operating system does the following activities related to distributed environment.
 OS Distributes computation logics among several physical processors.
 The processors do not share memory or a clock.
 Instead, each processor has its own local memory.
 OS manages the communications between the processors. They communicate with each
other through various communication lines.
Spooling
Spooling is an acronym for simultaneous peripheral operations on line. Spooling refers to putting
data of various I/O jobs in a buffer. This buffer is a special area in memory or hard disk which is
accessible to I/O devices. Operating system does the following activites related to distributed
environment.
 OS handles I/O device data spooling as devices have different data access rates.
 OS maintains the spooling buffer which provides a waiting station where data can rest
while the slower device catches up.
 OS maintains parallel computation because of spooling process as a computer can
perform I/O in parallel fashion. It becomes possible to have the computer read data from
a tape, write data to disk and to write out to a tape printer while it is doing its computing
task.

Advantages
 The spooling operation uses a disk as a very large buffer.
 Spooling is capable of overlapping I/O operation for one job with processor operations
for another job.
Operating System - Processes
Process
A process is a program in execution. The execution of a process must progress in a sequential
fashion. Definition of process is following.
 A process is defined as an entity which represents the basic unit of work to be

implemented in the system.


Components of process are following.
S.N. Component & Description
Object Program
1
Code to be executed.
Data
2
Data to be used for executing the program.
Resources
3
While executing the program, it may require some resources.
Status
Verifies the status of the process execution. A process can run to completion only when all
4
requested resources have been allocated to the process. Two or more processes could be
executing the same program, each using their own data and resources.
Program
A program by itself is not a process. It is a static entity made up of program statement while
process is a dynamic entity. Program contains the instructions to be executed by processor.
A program takes a space at single place in main memory and continues to stay there. A program
does not perform any action by itself.
Process States
As a process executes, it changes state. The state of a process is defined as the current activity of
the process.
Process can have one of the following five states at a time.
S.N. State & Description
New
1
The process is being created.
Ready
2 The process is waiting to be assigned to a processor. Ready processes are waiting to have the
processor allocated to them by the operating system so that they can run.
Running
3
Process instructions are being executed (i.e. The process that is currently being executed).
4 Waiting
The process is waiting for some event to occur (such as the completion of an I/O operation).
Terminated
5
The process has finished execution.

Process Control Block, PCB


Each process is represented in the operating system by a process control block (PCB) also called
a task control block. PCB is the data structure used by the operating system. Operating system
groups all information that needs about particular process.

PCB contains many pieces of information associated with a specific process which are described
below.
S.N. Information & Description
Pointer
1 Pointer points to another process control block. Pointer is used for maintaining the scheduling
list.
Process State
2
Process state may be new, ready, running, waiting and so on.
Program Counter
3
Program Counter indicates the address of the next instruction to be executed for this process.
CPU registers
4 CPU registers include general purpose register, stack pointers, index registers and accumulators
etc. number of register and type of register totally depends upon the computer architecture.
Memory management information
This information may include the value of base and limit registers, the page tables, or the
5
segment tables depending on the memory system used by the operating system. This information
is useful for deallocating the memory when the process terminates.
Accounting information
6 This information includes the amount of CPU and real time used, time limits, job or process
numbers, account numbers etc.

Process control block includes CPU scheduling, I/O resource management, file management
information etc.. The PCB serves as the repository for any information which can vary from
process to process. Loader/linker sets flags and registers when a process is created. If that
process get suspended, the contents of the registers are saved on a stack and the pointer to the
particular stack frame is stored in the PCB. By this technique, the hardware state can be restored
so that the process can be scheduled to run again.

Operating System - Process Scheduling


Definition
The process scheduling is the activity of the process manager that handles the removal of the running
process from the CPU and the selection of another process on the basis of a particular strategy.
Process scheduling is an essential part of a Multiprogramming operating system. Such operating systems
allow more than one process to be loaded into the executable memory at a time and loaded process shares
the CPU using time multiplexing.
Scheduling Queues
Scheduling queues refers to queues of processes or devices. When the process enters into the system, then
this process is put into a job queue. This queue consists of all processes in the system. The operating
system also maintains other queues such as device queue. Device queue is a queue for which multiple
processes are waiting for a particular I/O device. Each device has its own device queue.
This figure shows the queuing diagram of process scheduling.
 Queue is represented by rectangular box.
 The circles represent the resources that serve the queues.
 The arrows indicate the process flow in the system.

Queues are of two types


 Ready queue
 Device queue
A newly arrived process is put in the ready queue. Processes waits in ready queue for allocating
the CPU. Once the CPU is assigned to a process, then that process will execute. While executing
the process, any one of the following events can occur.
 The process could issue an I/O request and then it would be placed in an I/O queue.
 The process could create new sub process and will wait for its termination.
 The process could be removed forcibly from the CPU, as a result of interrupt and put
back in the ready queue.
Two State Process Model
Two state process model refers to running and non-running states which are described below.
S.N. State & Description
Running
1 When new process is created by Operating System that process enters into the system as in the
running state.
Not Running
Processes that are not running are kept in queue, waiting for their turn to execute. Each entry in
the queue is a pointer to a particular process. Queue is implemented by using linked list. Use of
2
dispatcher is as follows. When a process is interrupted, that process is transferred in the waiting
queue. If the process has completed or aborted, the process is discarded. In either case, the
dispatcher then selects a process from the queue to execute.
Schedulers
Schedulers are special system softwares which handles process scheduling in various ways.
Their main task is to select the jobs to be submitted into the system and to decide which process
to run. Schedulers are of three types
 Long Term Scheduler
 Short Term Scheduler
 Medium Term Scheduler
Long Term Scheduler
It is also called job scheduler. Long term scheduler determines which programs are admitted to
the system for processing. Job scheduler selects processes from the queue and loads them into
memory for execution. Process loads into the memory for CPU scheduling. The primary
objective of the job scheduler is to provide a balanced mix of jobs, such as I/O bound and
processor bound. It also controls the degree of multiprogramming. If the degree of
multiprogramming is stable, then the average rate of process creation must be equal to the
average departure rate of processes leaving the system.
On some systems, the long term scheduler may not be available or minimal. Time-sharing
operating systems have no long term scheduler. When process changes the state from new to
ready, then there is use of long term scheduler.
Short Term Scheduler
It is also called CPU scheduler. Main objective is increasing system performance in accordance
with the chosen set of criteria. It is the change of ready state to running state of the process. CPU
scheduler selects process among the processes that are ready to execute and allocates CPU to one
of them.
Short term scheduler also known as dispatcher, execute most frequently and makes the fine
grained decision of which process to execute next. Short term scheduler is faster than long term
scheduler.
Medium Term Scheduler
Medium term scheduling is part of the swapping. It removes the processes from the memory. It
reduces the degree of multiprogramming. The medium term scheduler is in-charge of handling
the swapped out-processes.
Running process may become suspended if it makes an I/O request. Suspended processes cannot
make any progress towards completion. In this condition, to remove the process from memory
and make space for other process, the suspended process is moved to the secondary storage. This
process is called swapping, and the process is said to be swapped out or rolled out. Swapping
may be necessary to improve the process mix.
Comparison between Scheduler
S.N. Long Term Scheduler Short Term Scheduler Medium Term Scheduler
It is a process swapping
1 It is a job scheduler It is a CPU scheduler
scheduler.
Speed is lesser than short term Speed is fastest among other Speed is in between both short
2
scheduler two and long term scheduler.
It controls the degree of It provides lesser control over It reduces the degree of
3
multiprogramming degree of multiprogramming multiprogramming.
It is almost absent or minimal in It is also minimal in time It is a part of Time sharing
4
time sharing system sharing system systems.
It selects processes from pool It can re-introduce the process
It selects those processes
5 and loads them into memory into memory and execution can
which are ready to execute
for execution be continued.
Context Switch
A context switch is the mechanism to store and restore the state or context of a CPU in Process
Control block so that a process execution can be resumed from the same point at a later time.
Using this technique a context switcher enables multiple processes to share a single CPU.
Context switching is an essential part of a multitasking operating system features.
When the scheduler switches the CPU from executing one process to execute another, the
context switcher saves the content of all processor registers for the process being removed from
the CPU, in its process descriptor. The context of a process is represented in the process control
block of a process.
Context switch time is pure overhead. Context switching can significantly affect performance as
modern computers have a lot of general and status registers to be saved. Content switching times
are highly dependent on hardware support. Context switch requires ( n + m ) bxK time units to
save the state of the processor with n general registers, assuming b are the store operations are
required to save n and m registers of two process control blocks and each store instruction
requires K time units.

Some hardware systems employ two or more sets of processor registers to reduce the amount of
context switching time. When the process is switched, the following information is stored.
 Program Counter
 Scheduling Information
 Base and limit register value
 Currently used register
 Changed State
 I/O State
 Accounting
Inter-process Communication
INTRODUCTION
Inter-process communication (IPC) includes thread synchronization and data exchange between threads
beyond the process boundaries. If threads belong to the same process, they execute in
the same address space, i.e. they can access global (static) data or heap directly, without the help
of the operating system. However, if threads belong to different processes, they cannot access
each other’s address spaces without the help of the operating system.
There are two fundamentally different approaches in IPC:
- processes are residing on the same computer
- processes are residing on different computers
The first case is easier to implement because processes can share memory either in the user space or in
the system space. This is equally true for uniprocessors and multiprocessors. In the second case the
computers do not share physical memory, they are connected via I/O devices (for example serial
communication or Ethernet). Therefore the processes residing in different computers cannot use
memory as a means for communication.

OS - Scheduling algorithms
We'll discuss four major scheduling algorithms here which are following
 First Come First Serve (FCFS) Scheduling
 Shortest-Job-First (SJF) Scheduling
 Priority Scheduling
 Round Robin(RR) Scheduling
 Multilevel Queue Scheduling
First Come First Serve (FCFS)
 Jobs are executed on first come, first serve basis.
 Easy to understand and implement.
 Poor in performance as average wait time is high.

Wait time of each process is following


Process Wait Time : Service Time - Arrival Time
P0 0-0=0
P1 5-1=4
P2 8-2=6
P3 16 - 3 = 13
Average Wait Time: (0+4+6+13) / 4 = 5.55
Shortest Job First (SJF)
 Best approach to minimize waiting time.
 Impossible to implement
 Processer should know in advance how much time process will take.

Wait time of each process is following


Process Wait Time : Service Time - Arrival Time
P0 3-0=3
P1 0-0=0
P2 16 - 2 = 14
P3 8-3=5
Average Wait Time: (3+0+14+5) / 4 = 5.50
Priority Based Scheduling
 Each process is assigned a priority. Process with highest priority is to be executed first
and so on.
 Processes with same priority are executed on first come first serve basis.
 Priority can be decided based on memory requirements, time requirements or any other
resource requirement.
Wait time of each process is following
Process Wait Time : Service Time - Arrival Time
P0 0-0=0
P1 3-1=2
P2 8-2=6
P3 16 - 3 = 13
Average Wait Time: (0+2+6+13) / 4 = 5.25
Round Robin Scheduling
 Each process is provided a fix time to execute called quantum.
 Once a process is executed for given time period. Process is preempted and other process
executes for given time period.
 Context switching is used to save states of preempted processes.

Wait time of each process is following


Process Wait Time : Service Time - Arrival Time
P0 (0-0) + (12-3) = 9
P1 (3-1) = 2
P2 (6-2) + (14-9) + (20-17) = 12
P3 (9-3) + (17-12) = 11
Average Wait Time: (9+2+12+11) / 4 = 8.5
Multi Queue Scheduling
 Multiple queues are maintained for processes.
 Each queue can have its own scheduling algorithms.
 Priorities are assigned to each queue.

Operating System - Multi-Threading


What is Thread?
A thread is a flow of execution through the process code, with its own program counter, system registers
and stack. A thread is also called a light weight process. Threads provide a way to improve application
performance through parallelism. Threads represent a software approach to improving performance of
operating system by reducing the overhead thread is equivalent to a classical process.
Each thread belongs to exactly one process and no thread can exist outside a process. Each thread
represents a separate flow of control. Threads have been successfully used in implementing network
servers and web server. They also provide a suitable foundation for parallel execution of applications on
shared memory multiprocessors. Following figure shows the working of the single and multithreaded
processes.
Difference between Process and Thread
S.N. Process Thread
Thread is light weight taking lesser resources than a
1 Process is heavy weight or resource intensive.
process.
Process switching needs interaction with Thread switching does not need to interact with
1
operating system. operating system.
In multiple processing environments each
All threads can share same set of open files, child
1 process executes the same code but has its
processes.
own memory and file resources.
If one process is blocked then no other process
While one thread is blocked and waiting, second
1 can execute until the first process is
thread in the same task can run.
unblocked.
Multiple processes without using threads use
1 Multiple threaded processes use fewer resources.
more resources.
In multiple processes each process operates One thread can read, write or change another
1
independently of the others. thread's data.
Advantages of Thread
 Thread minimize context switching time.
 Use of threads provides concurrency within a process.
 Efficient communication.
 Economy- It is more economical to create and context switch threads.
 Utilization of multiprocessor architectures to a greater scale and efficiency.
Types of Thread
Threads are implemented in following two ways
 User Level Threads -- User managed threads
 Kernel Level Threads -- Operating System managed threads acting on kernel, an
operating system core.
User Level Threads
In this case, application manages thread management kernel is not aware of the existence of
threads. The thread library contains code for creating and destroying threads, for passing
message and data between threads, for scheduling thread execution and for saving and restoring
thread contexts. The application begins with a single thread and begins running in that thread.
Advantages
 Thread switching does not require Kernel mode privileges.
 User level thread can run on any operating system.
 Scheduling can be application specific in the user level thread.
 User level threads are fast to create and manage.
Disadvantages
 In a typical operating system, most system calls are blocking.
 Multithreaded application cannot take advantage of multiprocessing.
Kernel Level Threads
In this case, thread management done by the Kernel. There is no thread management code in the
application area. Kernel threads are supported directly by the operating system. Any application
can be programmed to be multithreaded. All of the threads within an application are supported
within a single process.
The Kernel maintains context information for the process as a whole and for individuals threads
within the process. Scheduling by the Kernel is done on a thread basis. The Kernel performs
thread creation, scheduling and management in Kernel space. Kernel threads are generally
slower to create and manage than the user threads.
Advantages
 Kernel can simultaneously schedule multiple threads from the same process on multiple
processes.
 If one thread in a process is blocked, the Kernel can schedule another thread of the same
process.
 Kernel routines themselves can multithreaded.
Disadvantages
 Kernel threads are generally slower to create and manage than the user threads.
 Transfer of control from one thread to another within same process requires a mode
switch to the Kernel.
Multithreading Models
Some operating system provides a combined user level thread and Kernel level thread facility.
Solaris is a good example of this combined approach. In a combined system, multiple threads
within the same application can run in parallel on multiple processors and a blocking system call
need not block the entire process. Multithreading models are three types
 Many to many relationship.
 Many to one relationship.
 One to one relationship.
Many to Many Model
In this model, many user level threads multiplexes to the Kernel thread of smaller or equal
numbers. The number of Kernel threads may be specific to either a particular application or a
particular machine.
Following diagram shows the many to many model. In this model, developers can create as
many user threads as necessary and the corresponding Kernel threads can run in parallels on a
multiprocessor.

Many to One Model


Many to one model maps many user level threads to one Kernel level thread. Thread
management is done in user space. When thread makes a blocking system call, the entire process
will be blocks. Only one thread can access the Kernel at a time,so multiple threads are unable to
run in parallel on multiprocessors.
If the user level thread libraries are implemented in the operating system in such a way that
system does not support them then Kernel threads use the many to one relationship modes.
One to One Model
There is one to one relationship of user level thread to the kernel level [Link] model
provides more concurrency than the many to one model. It also another thread to run when a
thread makes a blocking system call. It support multiple thread to execute in parallel on
microprocessors.
Disadvantage of this model is that creating user thread requires the corresponding Kernel thread.
OS/2, windows NT and windows 2000 use one to one relationship model.

Difference between User Level & Kernel Level Thread


S.N. User Level Threads Kernel Level Thread
User level threads are faster to create Kernel level threads are slower to create and
1
and manage. manage.

Implementation is by a thread library at Operating system supports creation of Kernel


2
the user level. threads.

User level thread is generic and can run Kernel level thread is specific to the operating
3
on any operating system. system.

Multi-threaded application cannot take Kernel routines themselves can be


4
advantage of multiprocessing. multithreaded.

Deadlocks
A deadlock is a situation in which two or more competing actions are each waiting for the other to
finish, and thus neither ever does.
In a transactional database, a deadlock happens when two processes each within its own transaction
updates two rows of information but in the opposite order. For example, process A updates row 1 then
row 2 in the exact timeframe process B updates row 2 then row 1. Process A can't finish updating row
2 until process B is finished, but it cannot finish updating row 1 until process A finishes. No matter how
much time is allowed to pass, this situation will never resolve itself and because of this database
management systems will typically kill the transaction of the process that has done the least amount of
work.
In an operating system, a deadlock is a situation which occurs when a process or thread enters a
waiting state because a resource requested is being held by another waiting process, which in turn is
waiting for another resource. If a process is unable to change its state indefinitely because the
resources requested by it are being used by another waiting process, then the system is said to be in a
deadlock.[1]
Deadlock is a common problem in multiprocessing systems, parallel computing and distributed
systems, where software and hardware locks are used to handle shared resources and implement
process synchronization.[2]

Necessary condition
A deadlockers situation can arise if all of the following conditions hold simultaneously in a system:[1]
1. Mutual Exclusion: At least one resource must be held in a non-sharable mode.[1] Only one
process can use the resource at any given instant of time.
2. Hold and Wait or Resource Holding: A process is currently holding at least one resource and
requesting additional resources which are being held by other processes.

3. No Preemption: The operating system must not de-allocate resources once they have been
allocated; they must be released by the holding process voluntarily.

4. Circular Wait: A process must be waiting for a resource which is being held by another
process, which in turn is waiting for the first process to release the resource. In general, there is a
set of waiting processes, P = {P1, P2, ..., PN}, such that P1 is waiting for a resource held by P2, P2 is
waiting for a resource held by P3 and so on until PN is waiting for a resource held by P1.[1][7]

These four conditions are known as the Coffman conditions

Methods for Handling Deadlocks

 Generally speaking there are three ways of handling deadlocks:


1. Deadlock prevention or avoidance - Do not allow the system to get into a deadlocked
state.

2. Deadlock detection and recovery - Abort a process or preempt some resources when
deadlocks are detected.

3. Ignore the problem all together - If deadlocks only occur once a year or so, it may be
better to simply let them happen and reboot as necessary than to incur the constant
overhead and system performance penalties associated with deadlock prevention or
detection. This is the approach that both Windows and UNIX take.

 In order to avoid deadlocks, the system must have additional information about all processes.
In particular, the system must know what resources a process will or may request in the future.
( Ranging from a simple worst-case maximum to a complete resource request and release plan
for each process, depending on the particular algorithm. )

 Deadlock detection is fairly straightforward, but deadlock recovery requires either aborting
processes or preempting resources, neither of which is an attractive alternative.

 If deadlocks are neither prevented nor detected, then when a deadlock occurs the system will
gradually slow down, as more and more processes become stuck waiting for resources
currently held by the deadlock and by other waiting processes. Unfortunately this slowdown
can be indistinguishable from a general system slowdown when a real-time process has heavy
computing needs.

7.4 Deadlock Prevention


 Deadlocks can be prevented by preventing at least one of the four required conditions:

7.4.1 Mutual Exclusion


 Shared resources such as read-only files do not lead to deadlocks.
 Unfortunately some resources, such as printers and tape drives, require exclusive access by a
single process.

7.4.2 Hold and Wait


 To prevent this condition processes must be prevented from holding one or more resources
while simultaneously waiting for one or more others. There are several possibilities for this:
o Require that all processes request all resources at one time. This can be wasteful of
system resources if a process needs one resource early in its execution and doesn't need
some other resource until much later.

o Require that processes holding resources must release them before requesting new
resources, and then re-acquire the released resources along with the new ones in a
single new request. This can be a problem if a process has partially completed an
operation using a resource and then fails to get it re-allocated after releasing it.
o Either of the methods described above can lead to starvation if a process requires one
or more popular resources.

7.4.3 No Preemption
 Preemption of process resource allocations can prevent this condition of deadlocks, when it is
possible.
o One approach is that if a process is forced to wait when requesting a new resource,
then all other resources previously held by this process are implicitly released, ( preempted ),
forcing this process to re-acquire the old resources along with the new resources in a single
request, similar to the previous discussion.

o Another approach is that when a resource is requested and not available, then the
system looks to see what other processes currently have those resources and are themselves
blocked waiting for some other resource. If such a process is found, then some of their resources
may get preempted and added to the list of resources for which the process is waiting.

o Either of these approaches may be applicable for resources whose states are easily
saved and restored, such as registers and memory, but are generally not applicable to other
devices such as printers and tape drives.

7.4.4 Circular Wait


 One way to avoid circular wait is to number all resources, and to require that processes request
resources only in strictly increasing ( or decreasing ) order.
 In other words, in order to request resource Rj, a process must first release all Ri such that i >= j.
 One big challenge in this scheme is determining the relative ordering of the different resources

7.5 Deadlock Avoidance


 The general idea behind deadlock avoidance is to prevent deadlocks from ever happening, by
preventing at least one of the aforementioned conditions.
 This requires more information about each process, AND tends to lead to low device
utilization. ( I.e. it is a conservative approach. )

 In some algorithms the scheduler only needs to know the maximum number of each resource
that a process might potentially use. In more complex algorithms the scheduler can also take
advantage of the schedule of exactly what resources may be needed in what order.

 When a scheduler sees that starting a process or granting resource requests may lead to future
deadlocks, then that process is just not started or the request is not granted.
 A resource allocation state is defined by the number of available and allocated resources, and
the maximum requirements of all processes in the system.

7.5.1 Safe State


 A state is safe if the system can allocate all resources requested by all processes ( up to their
stated maximums ) without entering a deadlock state.
 More formally, a state is safe if there exists a safe sequence of processes { P0, P1, P2, ..., PN }
such that all of the resource requests for Pi can be granted using the resources currently
allocated to Pi and all processes Pj where j < i. ( I.e. if all the processes prior to Pi finish and
free up their resources, then Pi will be able to finish also, using the resources that they have
freed up. )

 If a safe sequence does not exist, then the system is in an unsafe state, which MAY lead to
deadlock. ( All safe states are deadlock free, but not all unsafe states lead to deadlocks. )

Deadlock handling
Most current operating systems cannot prevent a deadlock from occurring.[1] When a deadlock occurs,
different operating systems respond to them in different non-standard manners. Most approaches
work by preventing one of the four Coffman conditions from occurring, especially the fourth one.[9]
Major approaches are as follows.

Ignoring deadlock
In this approach, it is assumed that a deadlock will never occur. This is also an application of the
Ostrich algorithm.[9][10] This approach was initially used by MINIX and UNIX.[7] This is used when the
time intervals between occurrences of deadlocks are large and the data loss incurred each time is
tolerable.

Detection
Under deadlock detection, deadlocks are allowed to occur. Then the state of the system is examined to
detect that a deadlock has occurred and subsequently it is corrected. An algorithm is employed that
tracks resource allocation and process states, it rolls back and restarts one or more of the processes in
order to remove the detected deadlock. Detecting a deadlock that has already occurred is easily
possible since the resources that each process has locked and/or currently requested are known to the
resource scheduler of the operating system.[10]
Deadlock detection techniques include, but are not limited to, model checking. This approach
constructs a finite state-model on which it performs a progress analysis and finds all possible terminal
sets in the model. These then each represent a deadlock.
After a deadlock is detected, it can be corrected by using one of the following methods:

1. Process Termination: One or more process involved in the deadlock may be aborted. We can
choose to abort all processes involved in the deadlock. This ensures that deadlock is resolved
with certainty and speed. But the expense is high as partial computations will be lost. Or, we
can choose to abort one process at a time until the deadlock is resolved. This approach has
high overheads because after each abort an algorithm must determine whether the system is
still in deadlock. Several factors must be considered while choosing a candidate for
termination, such as priority and age of the process.
2. Resource Preemption: Resources allocated to various processes may be successively
preempted and allocated to other processes until the deadlock is broken.

Prevention
Deadlock prevention works by preventing one of the four Coffman conditions from occurring.
 Removing the mutual exclusion condition means that no process will have exclusive access to a
resource. This proves impossible for resources that cannot be spooled. But even with spooled resources,
deadlock could still occur. Algorithms that avoid mutual exclusion are called non-blocking synchronization
algorithms.
 The hold and wait or resource holding conditions may be removed by requiring processes to request
all the resources they will need before starting up (or before embarking upon a particular set of operations).
This advance knowledge is frequently difficult to satisfy and, in any case, is an inefficient use of resources.
Another way is to require processes to request resources only when it has none. Thus, first they must release
all their currently held resources before requesting all the resources they will need from scratch. This too is
often impractical. It is so because resources may be allocated and remain unused for long periods. Also, a
process requiring a popular resource may have to wait indefinitely, as such a resource may always be
allocated to some process, resulting in resource starvation.[1] (These algorithms, such as serializing tokens,
are known as the all-or-none algorithms.)
 The no preemption condition may also be difficult or impossible to avoid as a process has to be able to
have a resource for a certain amount of time, or the processing outcome may be inconsistent or thrashing
may occur. However, inability to enforce preemption may interfere with a priority algorithm. Preemption of
a "locked out" resource generally implies a rollback, and is to be avoided, since it is very costly in overhead.
Algorithms that allow preemption include lock-free and wait-free algorithms and optimistic concurrency
control.
 The final condition is the circular wait condition. Approaches that avoid circular waits include
disabling interrupts during critical sections and using a hierarchy to determine a partial ordering of
resources. If no obvious hierarchy exists, even the memory address of resources has been used to determine
ordering and resources are requested in the increasing order of the enumeration.[1]Dijkstra's solution can
also be used.

Avoidance
Deadlock can be avoided if certain information about processes are available to the operating system before
allocation of resources, such as which resources a process will consume in its lifetime. For every resource request,
the system sees whether granting the request will mean that the system will enter an unsafe state, meaning a
state that could result in deadlock. The system then only grants requests that will lead to safe states.[1] In order
for the system to be able to determine whether the next state will be safe or unsafe, it must know in advance at
any time:
 resources currently available
 resources currently allocated to each process
 resources that will be required and released by these processes in the future
It is possible for a process to be in an unsafe state but for this not to result in a deadlock. The notion of
safe/unsafe states only refers to the ability of the system to enter a deadlock state or not. For example, if a
process requests A which would result in an unsafe state, but releases B which would prevent circular wait, then
the state is unsafe but the system is not in deadlock.
One known algorithm that is used for deadlock avoidance is the Banker's algorithm, which requires resource
usage limit to be known in advance.[1] However, for many systems it is impossible to know in advance what every
process will request. This means that deadlock avoidance is often impossible.
Two other algorithms are Wait/Die and Wound/Wait, each of which uses a symmetry-breaking technique. In
both these algorithms there exists an older process (O) and a younger process (Y). Process age can be determined

by a timestamp at process creation time. Smaller timestamps are older processes, while larger timestamps
represent younger processes.
Wait/Die Wound/Wait
O needs a resource held by Y O waits Y dies
Y needs a resource held by O Y dies Y waits

Another way to avoid deadlock is to avoid blocking, for example by using Non-blocking
synchronization or Read-copy-update.
OS - Memory Management
Memory management is the functionality of an operating system which handles or manages
primary memory. Memory management keeps track of each and every memory location either it
is allocated to some process or it is free. It checks how much memory is to be allocated to
processes. It decides which process will get memory at what time. It tracks whenever some
memory gets freed or unallocated and correspondingly it updates the status.
Memory management provides protection by using two registers, a base register and a limit
register. The base register holds the smallest legal physical memory address and the limit register
specifies the size of the range. For example, if the base register holds 300000 and the limit
register is 1209000, then the program can legally access all addresses from 300000 through
411999.
Instructions and data to memory addresses can be done in following ways
 Compile time -- When it is known at compile time where the process will reside,
compile time binding is used to generate the absolute code.
 Load time -- When it is not known at compile time where the process will reside in
memory, then the compiler generates re-locatable code.
 Execution time -- If the process can be moved during its execution from one memory
segment to another, then binding must be delayed to be done at run time
Dynamic Loading
In dynamic loading, a routine of a program is not loaded until it is called by the program. All
routines are kept on disk in a re-locatable load format. The main program is loaded into memory
and is executed. Other routines methods or modules are loaded on request. Dynamic loading
makes better memory space utilization and unused routines are never loaded.
Dynamic Linking
Linking is the process of collecting and combining various modules of code and data into a
executable file that can be loaded into memory and executed. Operating system can link system
level libraries to a program. When it combines the libraries at load time, the linking is called
static linking and when this linking is done at the time of execution, it is called as dynamic
linking.
In static linking, libraries linked at compile time, so program code size becomes bigger whereas
in dynamic linking libraries linked at execution time so program code size remains smaller.
Logical versus Physical Address Space
An address generated by the CPU is a logical address whereas address actually available on
memory unit is a physical address. Logical address is also known a Virtual address.
Virtual and physical addresses are the same in compile-time and load-time address-binding
schemes. Virtual and physical addresses differ in execution-time address-binding scheme.
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 run-time mapping from virtual to physical address is done by the memory management unit
(MMU) which is a hardware device. MMU uses following mechanism to convert virtual address
to physical address.
 The value in the base register is added to every address generated by a user process which
is treated as offset at the time it is sent to memory. For example, if the base register value
is 10000, then an attempt by the user to use address location 100 will be dynamically
reallocated to location 10100.
 The user program deals with virtual addresses; it never sees the real physical addresses.
Swapping
Swapping is a mechanism in which a process can be swapped temporarily out of main memory
to a backing store , and then brought back into memory for continued execution.
Backing store is a usually a hard disk drive or any other secondary storage which fast in access
and large enough to accommodate copies of all memory images for all users. It must be capable
of providing direct access to these memory images.
Major time consuming part of swapping is transfer time. Total transfer time is directly
proportional to the amount of memory swapped. Let us assume that the user process is of size
100KB and the backing store is a standard hard disk with transfer rate of 1 MB per second. The
actual transfer of the 100K process to or from memory will take
100KB / 1000KB per second
= 1/10 second
= 100 milliseconds
Memory Allocation
Main memory usually has two partitions
 Low Memory -- Operating system resides in this memory.
 High Memory -- User processes then held in high memory.
Operating system uses the following memory allocation mechanism.
S.N. Memory Allocation Description
In this type of allocation, relocation-register scheme is used to protect user
processes from each other, and from changing operating-system code and
Single-partition
1 data. Relocation register contains value of smallest physical address whereas
allocation
limit register contains range of logical addresses. Each logical address must be
less than the limit register.
In this type of allocation, main memory is divided into a number of fixed-sized
partitions where each partition should contain only one process. When a
Multiple-partition
2 partition is free, a process is selected from the input queue and is loaded into
allocation
the free partition. When the process terminates, the partition becomes
available for another process.
Fragmentation
As processes are loaded and removed from memory, the free memory space is broken into little
pieces. It happens after sometimes that processes can not be allocated to memory blocks
considering their small size and memory blocks remains unused. This problem is known as
Fragmentation.
Fragmentation is of two types

S.N. Fragmentation Description


External Total memory space is enough to satisfy a request or to reside a process in it,
1
fragmentation but it is not contiguous so it cannot be used.
Internal Memory block assigned to process is bigger. Some portion of memory is left
2
fragmentation unused as it cannot be used by another process.
External fragmentation can be reduced by compaction or shuffle memory contents to place all
free memory together in one large block. To make compaction feasible, relocation should be
dynamic.
Paging
External fragmentation is avoided by using paging technique. Paging is a technique in which
physical memory is broken into blocks of the same size called pages (size is power of 2, between
512 bytes and 8192 bytes). When a process is to be executed, it's corresponding pages are loaded
into any available memory frames.
Logical address space of a process can be non-contiguous and a process is allocated physical
memory whenever the free memory frame is available. Operating system keeps track of all free
frames. Operating system needs n free frames to run a program of size n pages.
Address generated by CPU is divided into
 Page number (p) -- page number is used as an index into a page table which contains base
address of each page in physical memory.
 Page offset (d) -- page offset is combined with base address to define the physical memory
address.

Following figure show the paging table architecture.


Segmentation
Segmentation is a technique to break memory into logical pieces where each piece represents a
group of related information. For example ,data segments or code segment for each process, data
segment for operating system and so on. Segmentation can be implemented using or without
using paging.
Unlike paging, segment are having varying sizes and thus eliminates internal fragmentation.
External fragmentation still exists but to lesser extent.

Address generated by CPU is divided into


 Segment number (s) -- segment number is used as an index into a segment table which
contains base address of each segment in physical memory and a limit of segment.
 Segment offset (o) -- segment offset is first checked against limit and then is combined
with base address to define the physical memory address.
Operating System - Virtual Memory
Virtual memory is a technique that allows the execution of processes which are not completely
available in memory. The main visible advantage of this scheme is that programs can be larger
than physical memory. Virtual memory is the separation of user logical memory from physical
memory.
This separation allows an extremely large virtual memory to be provided for programmers when
only a smaller physical memory is available. Following are the situations, when entire program is
not required to be loaded fully in main memory.
 User written error handling routines are used only when an error occured in the data or
computation.
 Certain options and features of a program may be used rarely.
 Many tables are assigned a fixed amount of address space even though only a small amount
of the table is actually used.
 The ability to execute a program that is only partially in memory would counter many
benefits.
 Less number of I/O would be needed to load or swap each user program into memory.
 A program would no longer be constrained by the amount of physical memory that is
available.
 Each user program could take less physical memory, more programs could be run the same
time, with a corresponding increase in CPU utilization and throughput.
Virtual memory is commonly implemented by demand paging. It can also be implemented in a
segmentation system. Demand segmentation can also be used to provide virtual memory.
Demand Paging
A demand paging system is quite similar to a paging system with swapping. When we want to
execute a process, we swap it into memory. Rather than swapping the entire process into
memory, however, we use a lazy swapper called pager.
When a process is to be swapped in, the pager guesses which pages will be used before the
process is swapped out 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.
Hardware support is required to distinguish between those pages that are in memory and those
pages that are on the disk using the valid-invalid bit scheme. Where valid and invalid pages can
be checked by checking the bit. Marking a page will have no effect if the process never attempts
to access the page. While the process executes and accesses pages that are memory resident,
execution proceeds normally.
Access to a page marked invalid causes a page-fault trap. This trap is the result of the operating
system's failure to bring the desired page into memory. But page fault can be handled as
following

Step Description
Check an internal table for this process, to determine whether the reference was a
Step 1
valid or it was an invalid memory access.
If the reference was invalid, terminate the process. If it was valid, but page have not
Step 2
yet brought in, page in the latter.
Step 3 Find a free frame.
Step 4 Schedule a disk operation to read the desired page into the newly allocated frame.
When the disk read is complete, modify the internal table kept with the process and
Step 5
the page table to indicate that the page is now in memory.
Restart the instruction that was interrupted by the illegal address trap. The process
can now access the page as though it had always been in memory. Therefore, the
Step 6
operating system reads the desired page into memory and restarts the process as
though the page had always been in memory.
Advantages
Following are the advantages of Demand Paging
 Large virtual memory.
 More efficient use of memory.
 Unconstrained multiprogramming. There is no limit on degree of multiprogramming.
Disadvantages
Following are the disadvantages of Demand Paging
 Number of tables and amount of processor overhead for handling page interrupts are
greater than in the case of the simple paged management techniques.
 Due to the lack of an explicit constraints on a jobs address space size.
Page Replacement Algorithm
Page replacement algorithms are the techniques using which Operating System decides which
memory pages to swap out, write to disk when a page of memory needs to be allocated. Paging
happens whenever a page fault occurs and a free page cannot be used for allocation purpose
accounting to reason that pages are not available or the number of free pages is lower than
required pages.
When the page that was selected for replacement and was paged out, is referenced again then it
has to read in from disk, and this requires for I/O completion. This process determines the quality
of the page replacement algorithm: the lesser the time waiting for page-ins, the better is the
algorithm. A page replacement algorithm looks at the limited information about accessing the
pages provided by hardware, and tries to select which pages should be replaced to minimize the
total number of page misses, while balancing it with the costs of primary storage and processor
time of the algorithm itself. There are many different page replacement algorithms. We evaluate
an algorithm by running it on a particular string of memory reference and computing the number
of page faults.
Reference String
The string of memory references is called reference string. Reference strings are generated
artificially or by tracing a given system and recording the address of each memory reference. The
latter choice produces a large number of data, where we note two things.
 For a given page size we need to consider only the page number, not the entire address.
 If we have a reference to a page p, then any immediately following references to page p
will never cause a page fault. Page p will be in memory after the first reference; the
immediately following references will not fault.
 For example, consider the following sequence of addresses - 123,215,600,1234,76,96
 If page size is 100 then the reference string is 1,2,6,12,0,0
First In First Out (FIFO) algorithm
 Oldest page in main memory is the one which will be selected for replacement.
 Easy to implement, keep a list, replace pages from the tail and add new pages at the head.
Optimal Page algorithm
 An optimal page-replacement algorithm has the lowest page-fault rate of all algorithms.
An optimal page-replacement algorithm exists, and has been called OPT or MIN.
 Replace the page that will not be used for the longest period of time . Use the time when
a page is to be used.

Least Recently Used (LRU) algorithm


 Page which has not been used for the longest time in main memory is the one which will
be selected for replacement.
 Easy to implement, keep a list, replace pages by looking back into time.

Page Buffering algorithm


 To get process start quickly, keep a pool of free frames.
 On page fault, select a page to be replaced.
 Write new page in the frame of free pool, mark the page table and restart the process.
 Now write the dirty page out of disk and place the frame holding replaced page in free
pool.
Least frequently Used(LFU) algorithm
 Page with the smallest count is the one which will be selected for replacement.
 This algorithm suffers from the situation in which a page is used heavily during the initial
phase of a process, but then is never used again.
Most frequently Used(LFU) algorithm
 This algorithm is based on the argument that the page with the smallest count was
probably just brought in and has yet to be used.
Operating System - I/O Hardware
Overview
Computers operate on many kinds of devices. General types include storage devices (disks,
tapes), transmission devices (network cards, modems), and human-interface devices (screen,
keyboard, mouse). Other devices are more specialized. A device communicates with a computer
system by sending signals over a cable or even through the air.
The device communicates with the machine via a connection point termed a port (for example, a
serial port). If one or more devices use a common set of wires, the connection is called a [Link]
other terms, a bus is a set of wires and a rigidly defined protocol that specifies a set of messages
that can be sent on the wires.
Daisy chain
When device A has a cable that plugs into device B, and device B has a cable that plugs into
device C, and device C plugs into a port on the computer, this arrangement is called a daisy
chain. It usually operates as a bus.
Controller
A controller is a collection of electronics that can operate a port, a bus, or a device. A serial-port
controller is an example of a simple device controller. This is a single chip in the computer that
controls the signals on the wires of a serial port.
The SCSI bus controller is often implemented as a separate circuit board (a host adapter) that
plugs into the computer. It contains a processor, microcode, and some private memory to enable
it to process the SCSI protocol messages. Some devices have their own built-in controllers.
I/O port
An I/O port typically consists of four registers, called the status ,control, data-in, and data-out
registers.
S.N. Register & Description
Status Register
The status register contains bits that can be read by the host. These bits indicate states such as
1
whether the current command has completed, whether a byte is available to be read from the
data-in register, and whether there has been a device error.
Control register
The control register can be written by the host to start a command or to change the mode of a
2 device. For instance, a certain bit in the control register of a serial port chooses between full-duplex
and half-duplex communication, another enables parity checking, a third bit sets the word length to
7 or 8 bits, and other bits select one of the speeds supported by the serial port.
Data-in register
3
The data-in register is read by the host to get input.
Data-out register
4
The data out register is written by the host to send output.
Polling
Polling is a process by which a host waits for controller [Link] is a looping process, reading
the status register over and over until the busy bit of status register becomes clear. The controller
uses/sets the busy bit when it is busy working on a command, and clears the busy bit when it is
ready to accept the next command. The host signals its wish via the command-ready bit in the
command register. The host sets the command-ready bit when a command is available for the
controller to execute.
In the following example, the host writes output through a port, coordinating with the controller
by handshaking
 The host repeatedly reads the busy bit until that bit becomes clear.
 The host sets the write bit in the command register and writes a byte into the data-out register.
 The host sets the command-ready bit.
 When the controller notices that the command-ready bit is set, it sets the busy bit.
 The controller reads the command register and sees the write command.
 It reads the data-out register to get the byte, and does the I/O to the device.
 The controller clears the command-ready bit, clears the error bit in the status register to indicate
that the device I/O succeeded, and clears the busy bit to indicate that it is finished.
I/O devices
I/O Devices can be categorized into following category.
S.N. Category & Description
Human readable
1 Human Readable devices are suitable for communicating with the computer user. Examples are
printers, video display terminals, keyboard etc.
Machine readable
2 Machine Readable devices are suitable for communicating with electronic equipment. Examples are
disk and tape drives, sensors, controllers and actuators.
Communication
2 Communication devices are suitable for communicating with remote devices. Examples are digital
line drivers and modems.

Following are the differences between I/O Devices


S.N. Criteria & Description
Data rate
1
There may be differences of several orders of magnitude between the data transfer rates.
Application
2
Different devices have different use in the system.
Complexity of Control
3
A disk is much more complex whereas printer requires simple control interface.
Unit of transfer
4
Data may be transferred as a stream of bytes or characters or in larger blocks.
Data representation
5
Different data encoding schemes are used for different devices.
Error Conditions
6
The nature of errors differs widely from one device to another.
Direct Memory Access (DMA)
Many computers avoid burdening the main CPU with programmed I/O by offloading some of this work
to a special purpose processor. This type of processor is called, a Direct Memory Access(DMA)
controller. A special control unit is used to transfer block of data directly between an external device and
the main memory, without intervention by the processor. This approach is called Direct Memory
Access(DMA).
DMA can be used with either polling or interrupt software. DMA is particularly useful on devices like
disks, where many bytes of information can be transferred in single I/O operations. When used with an
interrupt, the CPU is notified only after the entire block of data has been transferred. For each byte or
word transferred, it must provide the memory address and all the bus signals controlling the data transfer.
Interaction with a device controller is managed through a device driver.
Handshaking is a process between the DMA controller and the device controller. It is performed via wires
using terms DMA request and DMA acknowledge.
Step Description
1 Device driver is instructed to transfer disk data to a buffer address X.
2 Device driver then instruct disk controller to transfer data to buffer.
3 Disk controller starts DMA transfer.
4 Disk controller sends each byte to DMA controller.
DMA controller transfers bytes to buffer, increases the memory address, decreases the counter C
5
until C becomes zero.
6 When C becomes zero, DMA interrupts CPU to signal transfer completion.
Device Controllers
A computer system contains a many types of I/O devices and their respective controllers
 network card
 graphics adapter
 disk controller
 DVD-ROM controller
 serial port
 USB
 sound card
Operating System - I/O Softwares
Interrupts
The CPU hardware uses an interrupt request line wire which helps CPU to sense after executing
every instruction. When the CPU checks that a controller has put a signal on the interrupt request
line, the CPU saves a state, such as the current value of the instruction pointer, and jumps to the
interrupt handler routine at a fixed address. The interrupt handler part determines the cause of the
interrupt, performs the necessary processing and executes a interrupt instruction to return the
CPU to its execution state.
The basic mechanism of interrurpt enables the CPU to respond to an asynchronous event, such as
when a device controller become ready for service. Most CPUs have two interrupt request lines.
 non-maskable interrupt - Such kind of interrupts are reserved for events like
unrecoverable memory errors.
 maskable interrupt - Such interrupts can be switched off by the CPU before the
execution of critical instructions that must not be interrupted.
The interrupt mechanism accepts an address - a number that selects a specific interrupt handling
routine/function from a small [Link] most architectures, this address is an offset stored in a table
called the interrupt vector table. This vector contains the memory addresses of specialized
interrupt handlers.
Application I/O Interface
Application I/O Interface represents the structuring techniques and interfaces for the operating
system to enable I/O devices to be treated in a standard, uniform way. The actual differences lies
kernel level modules called device drivers which are custom tailored to corresponding devices
but show one of the standard interfaces to applications. The purpose of the device-driver layer is
to hide the differences among device controllers from the I/O subsystem of the kernel, such as
the I/O system calls. Following are the characteristics of I/O interfaces with respected to devices.
 Character-stream / block - A character-stream device transfers bytes in one by one
fashion, whereas a block device transfers a complete unit of bytes.
 Sequential / random-access - A sequential device transfers data in a fixed order
determined by the device, random-access device can be instructed to seek position to any
of the available data storage locations.
 Synchronous / asynchronous - A synchronous device performs data transfers with
known response time where as an asynchronous device shows irregular or unpredictable
response time.
 Sharable / dedicated - A sharable device can be used concurrently by several processes
or threads but a dedicated device cannot be used.
 Speed of operation - Device speeds may range from a few bytes per second to a few
gigabytes per second.
 Read-write, read only, or write only - Some devices perform both input and output, but
others support only one data direction that is read only.
Clocks
Clocks are also called timers. The clock software takes the form of a device driver though a
clock is neither a blocking device nor a character based device. The clock software is the clock
driver. The exact function of the clock driver may vary depending on operating system.
Generally, the functions of the clock driver include the following.
S.N. Task Description
The clock driver implements the time of day or the real
1 Maintaining the time of the day time clock [Link] requires incrementing a counter
at each clock tick.
As a process is started, the scheduler initializes the
quantum counter in clock ticks for the process. The
clock driver decrements the quantum counter by 1, at
2 Preventing processes from running too long every clock interrupt. When the counter gets to zero ,
clock driver calls the scheduler to set up another
process. Thus clock driver helps in preventing
processes from running longer than time slice allowed.
Another function performed by clock driver is doing
3 Accounting for CPU usage CPU accounting. CPU accounting implies telling how
long the process has run.
Watchdog timers are the timers set by certain parts of
Providing watchdog timers for parts of the the system. For example, to use a floppy disk, the
4
system itself system must turn on the motor and then wait about
500msec for it to comes up to speed.
Kernel I/O Subsystem
Kernel I/O Subsystem is responsible to provide many services related to I/O. Following are some
of the services provided.
 Scheduling - Kernel schedules a set of I/O requests to determine a good order in which to
execute them. When an application issues a blocking I/O system call, the request is placed on the
queue for that device. The Kernel I/O scheduler rearranges the order of the queue to improve the
overall system efficiency and the average response time experienced by the applications.
 Buffering - Kernel I/O Subsystem maintains a memory area known as buffer that stores data
while they are transferred between two devices or between a device with an application operation.
Buffering is done to cope with a speed mismatch between the producer and consumer of a data
stream or to adapt between devices that have different data transfer sizes.
 Caching - Kernel maintains cache memory which is region of fast memory that holds copies of
data. Access to the cached copy is more efficient than access to the original.
 Spooling and Device Reservation A spool is a buffer that holds output for a device, such as a
printer, that cannot accept interleaved data streams. The spooling system copies the queued spool
files to the printer one at a time. In some operating systems, spooling is managed by a system
daemon process. In other operating systems, it is handled by an in kernel thread.
 Error Handling An operating system that uses protected memory can guard against many kinds
of hardware and application errors.
Device driver
Device driver is a program or routine developed for an I/O device. A device driver implements I/O
operations or behaviours on a specific class of devices. For example a system supports one or a number of
multiple brands of terminals, all slightly different terminals may have a single terminal driver. In the
layered structure of I/O system, device driver lies between interrupt handler and device independent I/O
software. The job of a device driver are following.
 To accept request from the device independent software above it.
 To see to it that the request is executed.
How a device driver handles a request is as follows: Suppose a request comes to read a block N.
If the driver is idle at the time a request arrives, it starts carrying out the request immediately.
Otherwise, if the driver is already busy with some other request, it places the new request in the
queue of pending requests.

Operating System - File System


File
A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical [Link] general, a file is a sequence of bits, bytes,
lines or records whose meaning is defined by the files creator and user.
File Structure
File structure is a structure, which is according to a required format that operating system can
understand.
 A file has a certain defined structure according to its type.
 A text file is a sequence of characters organized into lines.
 A source file is a sequence of procedures and functions.
 An object file is a sequence of bytes organized into blocks that are understandable by the
machine.
 When operating system defines different file structures, it also contains the code to support these
file structure. Unix, MS-DOS support minimum number of file structure.
File Type
File type refers to the ability of the operating system to distinguish different types of file such as
text files source files and binary files etc. Many operating systems support many types of files.
Operating system like MS-DOS and UNIX have the following types of files:
Ordinary files
 These are the files that contain user information.
 These may have text, databases or executable program.
 The user can apply various operations on such files like add, modify, delete or even remove the
entire file.
Directory files
 These files contain list of file names and other information related to these files.
Special files:
 These files are also known as device files.
 These files represent physical device like disks, terminals, printers, networks, tape drive etc.

These files are of two types


 Character special files - data is handled character by character as in case of terminals or
printers.
 Block special files - data is handled in blocks as in the case of disks and tapes.
File Access Mechanisms
File access mechanism refers to the manner in which the records of a file may be accessed. There
are several ways to access files
 Sequential access
 Direct/Random access
 Indexed sequential access
Sequential access
A sequential access is that in which the records are accessed in some sequence i.e the
information in the file is processed in order, one record after the other. This access method is the
most primitive one. Example: Compilers usually access files in this fashion.
Direct/Random access
 Random access file organization provides, accessing the records directly.
 Each record has its own address on the file with by the help of which it can be directly
accessed for reading or writing.
 The records need not be in any sequence within the file and they need not be in adjacent
locations on the storage medium.
Indexed sequential access
 This mechanism is built up on base of sequential access.
 An index is created for each file which contains pointers to various blocks.
 Index is searched sequentially and its pointer is used to access the file directly.
Space Allocation
Files are allocated disk spaces by operating system. Operating systems deploy following three
main ways to allocate disk space to files.
 Contiguous Allocation
 Linked Allocation
 Indexed Allocation
Contiguous Allocation
 Each file occupy a contiguous address space on disk.
 Assigned disk address is in linear order.
 Easy to implement.
 External fragmentation is a major issue with this type of allocation technique.
Linked Allocation
 Each file carries a list of links to disk blocks.
 Directory contains link / pointer to first block of a file.
 No external fragmentation
 Effectively used in sequential access file.
 Inefficient in case of direct access file.
Indexed Allocation
 Provides solutions to problems of contigous and linked allocation.
 A index block is created having all pointers to files.
 Each file has its own index block which stores the addresses of disk space occupied by
the file.
 Directory contains the addresses of index blocks of files.

Operating System - Security


Security refers to providing a protection system to computer system resources such as CPU,
memory, disk, software programs and most importantly data/information stored in the computer
system. If a computer program is run by unauthorized user then he/she may cause severe damage
to computer or data stored in it. So a computer system must be protected against unauthorized
access, malicious access to system memory, viruses, worms etc. We're going to discuss
following topics in this article.
 Authentication
 One Time passwords
 Program Threats
 System Threats
 Computer Security Classifications
Authentication
Authentication refers to identifying the each user of the system and associating the executing
programs with those users. It is the responsibility of the Operating System to create a protection
system which ensures that a user who is running a particular program is authentic. Operating
Systems generally identifies/authenticates users using following three ways:
 Username / Password - User need to enter a registered username and password with
Operating system to login into the system.
 User card/key - User need to punch card in card slot, or enter key generated by key
generator in option provided by operating system to login into the system.
 User attribute - fingerprint/ eye retina pattern/ signature - User need to pass his/her
attribute via designated input device used by operating system to login into the system.
One Time passwords
One time passwords provides additional security along with normal authentication. In One-Time
Password system, a unique password is required every time user tries to login into the system. Once a
one-time password is used then it cannot be used again. One time password are implemented in various
ways.
 Random numbers - Users are provided cards having numbers printed along with
corresponding alphabets. System asks for numbers corresponding to few alphabets
randomly chosen.
 Secret key - User are provided a hardware device which can create a secret id mapped
with user id. System asks for such secret id which is to be generated every time prior to
login.
 Network password - Some commercial applications send one time password to user on
registered mobile/ email which is required to be entered prior to login.
Program Threats
Operating system's processes and kernel do the designated task as instructed. If a user program
made these process do malicious tasks then it is known as Program Threats. One of the common
example of program threat is a program installed in a computer which can store and send user
credentials via network to some hacker. Following is the list of some well known program
threats.
 Trojan Horse - Such program traps user login credentials and stores them to send to
malicious user who can later on login to computer and can access system resources.
 Trap Door - If a program which is designed to work as required, have a security hole in
its code and perform illegal action without knowledge of user then it is called to have a
trap door.
 Logic Bomb - Logic bomb is a situation when a program misbehaves only when certain
conditions met otherwise it works as a genuine program. It is harder to detect.
 Virus - Virus as name suggest can replicate themselves on computer system .They are
highly dangerous and can modify/delete user files, crash systems. A virus is generatlly a
small code embedded in a program. As user accesses the program, the virus starts getting
embedded in other files/ programs and can make system unusable for user.
System Threats
System threats refers to misuse of system services and network connections to put user in
trouble. System threats can be used to launch program threats on a complete network called as
program attack. System threats creates such an environment that operating system resources/
user files are mis-used. Following is the list of some well known system threats.
 Worm -Worm is a process which can choked down a system performance by using
system resources to extreme levels.A Worm process generates its multiple copies where
each copy uses system resources, prevents all other processes to get required resources.
Worms processes can even shut down an entire network.
 Port Scanning - Port scanning is a mechanism or means by which a hacker can detects
system vulnerabilities to make an attack on the system.
 Denial of Service - Denial of service attacks normally prevents user to make legitimate
use of the system. For example user may not be able to use internet if denial of service
attacks browser's content settings.
Computer Security Classifications
As per the U.S. Department of Defense Trusted Computer System's Evaluation Criteria there are
four security classifications in computer systems: A, B, C, and D. This is widely used
specifications to determine and model the security of systems and of security solutions.
Following is the brief description of each classfication.
Classification
S.N. Description
Type
Highest Level. Uses formal design specifications and verification techniques.
1 Type A
Grants a high degree of assurance of process security.
2 Type B Provides mandatory protection system. Have all the properties of a class C2
system. Attaches a sensitivity label to each object. It is of three types.
 B1 - Maintains the security label of each object in the system. Label
is used for making decisions to access control.
 B2 - Extends the sensitivity labels to each system resource, such as
storage objects, supports covert channels and auditing of events.
 B3 - Allows creating lists or user groups for access-control to grant
access or revoke access to a given named object.
Provides protection and user accountability using audit capabilities. It is of two
types.
 C1 - Incorporates controls so that users can protect their private
3 Type C information and keep other users from accidentally reading / deleting
their data. UNIX versions are mostly Cl class.
 C2 - Adds an individual-level access control to the capabilities of a
Cl level system
4 Type D Lowest level. Minimum protection. MS-DOS, Window 3.1 fall in this category.

Operating System - Linux


Linux is one of popular version of UNIX operating System. It is open source as its source code is
freely available. It is free to use. Linux was designed considering UNIX compatibility. It's
functionality list is quite similar to that of UNIX.
Components of Linux System
Linux Operating System has primarily three components
 Kernel - Kernel is the core part of Linux. It is responsible for all major activities of this
operating system. It is consists of various modules and it interacts directly with the
underlying hardware. Kernel provides the required abstraction to hide low level hardware
details to system or application programs.
 System Library - System libraries are special functions or programs using which
application programs or system utilities accesses Kernel's features. These libraries
implements most of the functionalities of the operating system and do not requires kernel
module's code access rights.
 System Utility - System Utility programs are responsible to do specialized, individual
level tasks.
Kernel Mode vs User Mode
Kernel component code executes in a special privileged mode called kernel mode with full
access to all resources of the computer. This code represents a single process, executes in single
address space and do not require any context switch and hence is very efficient and fast. Kernel
runs each processes and provides system services to processes, provides protected access to
hardwares to processes.
Support code which is not required to run in kernel mode is in System Library. User programs
and other system programs works in User Mode which has no access to system hardwares and
kernel code. User programs/ utilities use System libraries to access Kernel functions to get
system's low level tasks.
Basic Features
Following are some of the important features of Linux Operating System.
 Portable - Portability means softwares can works on different types of hardwares in
same [Link] kernel and application programs supports their installation on any kind
of hardware platform.
 Open Source - Linux source code is freely available and it is community based
development project. Multiple teams works in collaboration to enhance the capability of
Linux operating system and it is continuously evolving.
 Multi-User - Linux is a multiuser system means multiple users can access system
resources like memory/ ram/ application programs at same time.
 Multiprogramming - Linux is a multiprogramming system means multiple applications
can run at same time.
 Hierarchical File System - Linux provides a standard file structure in which system
files/ user files are arranged.
 Shell - Linux provides a special interpreter program which can be used to execute
commands of the operating system. It can be used to do various types of operations, call
application programs etc.
 Security - Linux provides user security using authentication features like password
protection/ controlled access to specific files/ encryption of data.
Architecture

Linux System Architecture is consists of following layers


 Hardware layer - Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc).
 Kernel - Core component of Operating System, interacts directly with hardware,
provides low level services to upper layer components.
 Shell - An interface to kernel, hiding complexity of kernel's functions from users. Takes
commands from user and executes kernel's functions.
 Utilities - Utility programs giving user most of the functionalities of an operating
systems.
Operating system Questions
Question one
a. Explain the following terms as used in operating systems:
[Link] language [2Marks]
[Link] nuclear [2Marks]
[Link] interrupts [2Marks]
IV. Thrashing [2Marks]
b. With the aid of a diagram, explain the relationship between operating system, computer
hardware,utility programs and application programs [6Marks]
c. Identify four functions of the operating system. [4Marks]
d. Describe at least two operating system structures. [4Marks

e.
i. Briefly explain four main performance criteria used to select a scheduling algorithm. [4Marks]
ii. Describe the four conditions for deadlock in Operating System. [4Marks]

Question two
a) The process control block is a data structure containing certain important information about
theprocess. Identify the information contained in the PCB. [6Marks]
b) Briefly explain six factors that may lead to a process switch. [6Marks]
c) Discuss at least four objectives of file management. [8Marks]
Question three
a) Security goals of any computer system are decided by its security policies. Briefly explain three
computer security goals that can be set in an operating system. [6Marks]
b) State four types of security threats to consider when designing and implementing any operating
system. [4Marks]
c) Most Modern Operating Systems support memory management with paging. Briefly explain the
following.
i) Page replacement algorithms [4Marks]
ii) Fetch policies, outlining the two classes [3Marks]
iii) Placement algorithm for non-paged system. [3Marks]
Question four
a) Distinguish between a file system and a file control block. [4Marks]
b) List four operations that are associated with files [4Marks]
c) Discuss in detail four file organization methods. [8Marks]
d) Describe two techniques that can be used to manage disk free space [4Marks]

Question five
1. Distinguish between the following pairs of terms:
a) Starvation and Deadlock [2Marks]
b) Fault avoidance and Error detection [2Marks]
c) Device driver and Device controller [2Marks]
d) Paging and segmentation [2Marks]
2. Explain five desirable features of a process scheduling algorithm [5Marks]
3. Describe the operation of Round Robin and Multilevel Feedback Queues scheduling
algorithms. [5Marks]
4. Outline any two factors to consider in operating system design [2Marks]

Question six
Define briefly the following terms: (2X4=8 Marks)
(i) Operating system
(ii) (ii) Scheduling
(iii) (iii)Linking and
(iv) (iv) Relocating
Explain the primary objectives of the following operating systems (2X3=6 Marks)

(i) Time-sharing
(ii) Real-time system and
(iii) Distributed systems.
 State and explain the two fundamental relations among concurrent process (4 Marks)
 Explain the importance of interprocess synchronization (4 Marks)
 Distinguish between static and dynamic memory allocation schemes and explain how each
scheme
wastes storage. (6 Marks)
 Briefly explain the objective of computer security. (2 Marks)

Question seven
 What is the difference between a global state and a process switch? (4 Marks)
 Using a clearly labeled diagram describe the process-state transition diagram. (6 Marks)
 Briefly explain the concept of swapping. (2 Marks)
 When is a swapper invoked? (2 Marks)
 State two major responsibilities of an operating system swapper. (2 Marks)
(i) State the primary objective of a memory management system (2 Marks)
(ii) Explain the role of a memory manager in a multiprogramming environment (2 Marks)
Question eight
(a) (i) What is indefinite postponement? (2 Marks)
(ii) Explain how live lock can be prevented. (2 Marks)
(b) Explain the concept of mutual exclusion and state the general solution to the mutual exclusion
problem. (6 Marks)
(c) Differentiate between the following terms:
(i) Virtual addresses and physical addresses. (4 Marks)
(ii) Static relocation and dynamic relocation. (4 Marks)
(d) Describe the term path name with respect to file management. (2 Marks)

Question nine
a) (i) Discuss four objectives of the file-management system. (4Marks)
(ii) Distinguish between a flat directory and a hierarchical directory. (4Marks)
b) State three advantages of hierarchical directories as perceived by users. (3 Marks)
c) (i) Using a diagram show the possible traversal paths of jobs and programs through the
component
and queues of a computer system. (4 Marks)
(iii) State four events that can cause the short-term scheduler to be invoked. (2 Marks)
d) Explain briefly the multiple-level queues (MLQ) scheduling policy (3 Marks)

Question ten
(a) (i) What does data integrity entail? (3 Marks)
(ii) State three procedures and process that specify security policies. (3 Marks)
(b) Discuss the virtual memory as used in memory management for non-contiguous allocation.
(4 Marks)
(c) Explain the following replacement algorithm and state how each is implemented.
3
(i) First-in-First-out(FIFO) (4 Marks)
(ii) Not-Recently Used (Clock) NRU (4 Marks)
(d) State the two characteristic of I/O devices that define the input/output problem. (2 Marks)

Question eleven
a) Briefly discuss the EIGHT functions of an operating system. [8 Marks]
b) Briefly discuss any three (3) goals of scheduling. [6 Marks]
c) Shortest-Job-First provides the minimal average turnaround time for jobs. Show why this is true.
What is a disadvantage of this batch scheduling algorithm? [6 Marks]
Question twelve
a) Briefly discuss the four (4) control structures namely Memory tables, I/O tables, Files tables and
Process tables used by the operating system to manage processes. [8 Marks]
b) State the circumstances that may force the processor to switch execution of one process to
another.
[5 Marks]
c) Define the following terms:
i. Kernel [1 Mark]
ii. Dispatcher [1 Mark]
iii. Program counter [1 Mark]
iv. Scheduler [1 Mark]
d) Discuss the benefits of multiprogramming. [3 Marks]
2
Question thirteen
a) Using a well labeled diagram, describe the five-state process model including the suspend states.
[10 Marks]
b) Differentiate between the following terms:
i. Semaphores and monitors [2 Marks]
ii. Process and thread [2 Marks]
iii. Ready, Suspend and Blocked, Suspend [2 Marks]
iv. Preemptive and Non-preemptive scheduling [2 Marks]
v. Deadlock and Starvation [2 Marks]
Question fourteen
a) Describe the shortest-job-first (SJF) (3 Marks)
b) One of the techniques or dealing with deadlock is deadlock avoidance
i. Briefly describe the banker’s algorithm for deadlock avoidance (3 Marks)
ii. What are the advantages of deadlock avoidance over deadlock detection and recovery
(3 Marks)
c) i) What is a priority based process (7 Marks)
ii) With regard to priority based process give FOUR internal priorities (4 Marks)
Question Five
Consider the algorithm for mutual exclusion
Process 1 {
While true {
While (turn==1)
; /*do nothing * /
Critical section
Turn=2;
Other non critical section code
}
}
Process 2 {
While true {
While (turn==2)
3
; /*do nothing * /
Critical section
Turn=1;
Other non critical section code
}
}
a) Does it satisfy mutual exclusion? Explain (4 Marks)
b) Does it prevent deadlock? Explain (3 Marks)
c) What problem does this solution have? (4 Marks)
d) What are semaphores, locks and condition variables used for (9 Marks)

Question sixteen
a) Identify the FOUR categorizations of operating systems (4 Marks)
b) Distinguishing between multiprocessing and multitasking (4 Marks)
c) Give FOUR key functions of the operating system (4 Marks)
d) Describe the FOUR areas in the memory map (8 Marks)

Question seventeen
a) i) Identify the FOUR necessary and sufficient conditions for deadlocks (8 Marks)
ii) Give any TWO possible solutions to the problem in question 2a(i) (2 Marks)
b) Describe the three types of schedulers (6 Marks)
c) Explain TWO common strategies to allocate free partitions to ready processes (4 Marks)

Question eighteen
a) Describe the three classifications of input/output devices (12 Marks)
b)What is a file system (2 Marks)
c) Write short notes on the NTFS file system (6 Marks)

Question nineteen
a) Draw a diagram and explain how virtual addresses are converted into physical addresses
(9 Marks)
b) What is demand paging? (2 Marks)
c) Explain the TWO differences between internal and external fragmentations (4 Marks)
d) Describe the producer and consumer problem and a possible solution (5 Marks)
Question twenty
a) Name and describe 5 commands in LINUX/UNIX operating system (10 Marks)
b) Draw the structure of the UNIX operating system (6 Marks)
c) Give TWO advantages of UNIX/Linux over the windows operating system (4 Marks)
Question twenty one
a) Define the following terms used in OS; (5 Marks)
i. Computer
ii. System
iii. Data
iv. Information
v. Software
b) Define the term Operating System. (2 Marks)
c) Give FOUR solutions to the critical section problem in relation to mutual exclusion. (4 Marks)
d) Define semaphores giving a brief description on its actions. (2 Marks)
e) Using expressions and codes, explain how semaphores can be used to solve bounded buffer
problem. (7 Marks)
Question twenty two
a) Briefly explain the concept of a deadlock in operating systems. (4 Marks)
b) Explain FOUR necessary and sufficient conditions for a deadlock to occur. (8 Marks)
c) Explain FOUR ways of dealing with deadlocks. (8 Marks)
2
Question twenty three
a) State the history of OS explaining each of the FOUR generations. (4 Marks)
b) Describe the scheduling process explaining THREE types of schedulers. (7 Marks)
c) Explain the following scheduling algorithms; (9 Marks)
i. First Come First Served (FCFS)
ii. Shortest Job First (SJF)
iii. Round Robin

Question twenty four


a) State EIGHT functions of OS. (4 Marks)
b) Explain the concept of memory management. (2 Marks)
c) Give one advantage and one disadvantage of dynamic partitioning as used in memory
management.
(2 Marks)
d) Using diagram, explain the concept of paging, segmentation and virtual memory in relation to OS.
(12 Marks)

Question twenty five


a)Explain FIVE possible states that a process can be in. (5 Marks)
b) Explain THREE main categories of Input/Output devices. (3 Marks)
c)Using a well labeled diagram, describe the Input/Output hardware architecture. (5 Marks)
d) With help of a diagram, explain the concept of DMA. (3 Marks)
e)Describe file management and differentiate between file locking and fragmentation. (4 Marks)

Question twenty six


(a) Define briefly the following terms:
(i) Storage interleaving
(ii) cycle stealing
(iii)Virtual storage (6 Marks)
(b) Distinguish between the following terms
(i) Interrupt and polling
(ii) On-line and off-line operations
(iii) Direct memory Access (DMA) and pipeling (6 Marks)
(c) When an interrupt occurs several events may happen. Explain any three such events.(3 Marks)
(d) Discuss the following terms as used in asynchronous concurrent processes
i) Mutual exclusion
ii) Critical sections (4 Marks)
(e) (i) Explain why fragmentation occurs in fixed-partition multiprogramming system
(ii) What is coalescing of holes (4 Marks)
(f) (i) Differentiate between preemptive and non-preemptive scheduling. (4 Marks)
(ii) What is a file? (1 Marks)
2
Question twenty seven
a) (i) What is a process control block (PCB)? (2 Marks)
(ii) State four important information contained in a PCB (2 Marks)
b) (i) Give three reasons why suspending and resuming processes in important.
(ii) Draw and label the process state transition with suspend and resume. (4 Marks)
c) Explain the concept of a semaphore and the operation of P and V (Signal and Wait) (4 Marks)
d) Give an example of a simple resource deadlock and explain why the system is deadlocked.
(4 Marks)

Question twenty eight


a) Explain briefly the following real storage management strategies:
(i) Fetch strategies
(ii) Placement strategies
(iii) Replacement strategies (6 Marks)
b) Distinguish between contagious and non-contagious storage allocation. (4 Marks)
c) (i) Explain the concept of storage compaction in a variable partition multiprogramming
system. (3 Marks)
(ii)Give three disadvantage of storage compaction. (3 Marks)
(d) Explain how denying one or more of the necessary condition for deadlock may prevent
deadlock. (4 Marks)

Question twenty nine


a) (i) Differentiate between paging and segmentation system including the concept of virtual
address for the system. (6 Marks)
(ii) Discuss briefly the combined paged/segmented system within the virtual storage
organization. (4 Marks)
(b) Explain the following page replacement strategies
(i) The principal of optimality
(ii) Least-Recently Used (LRU) (4 Marks)
(c) Briefly explain the following terms with respect to virtual storage management
(i) Demand paging
(ii) Anticipatory paging
(iii) Page Release (6 Marks)
3
Question thirty
(a) Discuss briefly the following terms considered in the design of a scheduling discipline
objectives:
i) Fair
ii) Maximize throughput
iii) Be predictable and
iv) Degrade gracefully under heavy loads. (8 Marks)
(b) Discuss the multilevel feedback queues scheduling scheme and show how the scheme favors
short jobs and also how it favors I/O bounds jobs to get good I/O device utilization.(4 Marks)
(c) The file system generally contains the following terms: Access methods, file management,
auxiliary storage management and file integrity mechanisms. Explain each of the terms
clearly. (4 Marks)
(d) (i) State the two characteristic of I/O devices that define the input/output problem (2 Marks)
(ii) Explain the objectives of computer security. (2 Marks)

Question thirty one


(a) Define briefly the following terms:
(i) Throughput (ii) Response time (iii) Semaphore and (iv) deadlock (8 Marks)
(b) Describe the three states a process can be in while in the system. (6 Marks)
(c) Outline the differences between physical address and virtual address? (4 Marks)
(d) Describe the paging memory allocation scheme bringing out it’s advantages and disadvantages
over segmentation. (4 Marks)
(e) Describe the paging memory allocation scheme bringing out it’s advantages and disadvantages
over segmentation. (4 Marks)
(f) Discuss the two components that make up any I/O device. (4 Marks)

Question thirty two


a) Describe briefly the ways that can be used to terminate a process. (4 Marks)
b) What is a control structure that the operating system uses to keep the information of the process
context? Give the pieces of information that are likely to be in this structure. (4 Marks)
c) (i) What is a binary semaphore? (2 Marks)
(ii) Describe the signal and wait operation and how it is implemented in a semaphore. (4 Marks)
d) (i) Explain what a thread is? Give an example. (2 Marks)
2
(ii) What is the difference between a global switch and a process switch? (4 Marks)

Question thirty three


a) Clearly explain the compaction process in the main memory. (4 Marks)
b) Discuss how fragmentation manifest itself in each of the following type of virtual storage
system
(i) Segmentation (ii) Paging and (iii) Combined paging/segmentation. (6 Marks)
c) A system has two process and three identical resources. Each process needs a maximum of two
resources. Is deadlock possible? Explain your answer. (3Marks)
d) (i) Explain briefly the concept of deadlock prevention. (2 Marks)
(ii) Describe how the circular-wait condition can be prevented. (3 Marks)
(iii)Explain how deadlock involving consumable resources can occur. (2 Marks)
Question thirty four
(a) Briefly describe the following page replacement algorithms.
(i) First-in First out and (ii) Optimal (OPT) (4 Marks)
(b) (i) Discuss the disadvantages that a single level directory system has. (4Marks)
(ii) Give four directory operations in UNIX, explaining what they do. (4Marks)
(c) Discuss briefly and compare the working of Memory-Mapped I/O and the Direct Memory Access
(DMA) as ways of the processor communicating with the I/O devices. Why is the DMA preferred?
(6 Marks)
(d) Discuss four ways in which input and output devices may differ. (2 Marks)
Question thirty five
(a) (i) Explain briefly the objective of computer security. (2 Marks)
(ii) State three procedure and processes that specify security policies. (3 Marks)
(i) What does data integrity entail (3 Marks)
(b) Explain briefly the following terms with respect to inter-process synchronization
(i) Critical section and (ii) Mutual exclusion (4 Marks)
(c) Describe the three forms of explicit inter-process synchronization (6 Marks)
(d) Describe two ways in which a program can invoke services of the operating system.
(2 Marks)

Question thirty six


(a) Define briefly the following terms:
(i) Storage interleaving
(ii) cycle stealing
(iii)Virtual storage (6 Marks)
(b) Distinguish between the following terms
(i) Interrupt and polling
(ii) On-line and off-line operations
(iii) Direct memory Access (DMA) and pipeling (6 Marks)
(c) When an interrupt occurs several events may happen. Explain any three such events.(3 Marks)
(d) Discuss the following terms as used in asynchronous concurrent processes
i) Mutual exclusion
ii) Critical sections (4 Marks)
(e) (i) Explain why fragmentation occurs in fixed-partition multiprogramming system
(ii) What is coalescing of holes (4 Marks)
(f) (i) Differentiate between preemptive and non-preemptive scheduling. (4 Marks)
(ii) What is a file? (1 Marks)
2
Question thirty seven
a) (i) What is a process control block (PCB)? (2 Marks)
(ii) State four important information contained in a PCB (2 Marks)
b) (i) Give three reasons why suspending and resuming processes in important.
(ii) Draw and label the process state transition with suspend and resume. (4 Marks)
c) Explain the concept of a semaphore and the operation of P and V (Signal and Wait) (4 Marks)
d) Give an example of a simple resource deadlock and explain why the system is deadlocked.
(4 Marks)
Question thirty eight
a) Explain briefly the following real storage management strategies:
(i) Fetch strategies
(ii) Placement strategies
(iii) Replacement strategies (6 Marks)
b) Distinguish between contagious and non-contagious storage allocation. (4 Marks)
c) (i) Explain the concept of storage compaction in a variable partition multiprogramming
system. (3 Marks)
(ii)Give three disadvantage of storage compaction. (3 Marks)
(d) Explain how denying one or more of the necessary condition for deadlock may prevent
deadlock. (4 Marks)
Question thirty nine
a) (i) Differentiate between paging and segmentation system including the concept of virtual
address for the system. (6 Marks)
(ii) Discuss briefly the combined paged/segmented system within the virtual storage
organization. (4 Marks)
(b) Explain the following page replacement strategies
(i) The principal of optimality
(ii) Least-Recently Used (LRU) (4 Marks)
(c) Briefly explain the following terms with respect to virtual storage management
(i) Demand paging
(ii) Anticipatory paging
(iii) Page Release (6 Marks)
3
Question forty
(a) Discuss briefly the following terms considered in the design of a scheduling discipline
objectives:
i) Fair
ii) Maximize throughput
iii) Be predictable and
iv) Degrade gracefully under heavy loads. (8 Marks)
(b) Discuss the multilevel feedback queues scheduling scheme and show how the scheme favors
short jobs and also how it favors I/O bounds jobs to get good I/O device utilization.(4 Marks)
(c) The file system generally contains the following terms: Access methods, file management,
auxiliary storage management and file integrity mechanisms. Explain each of the terms
clearly. (4 Marks)
(d) (i) State the two characteristic of I/O devices that define the input/output problem (2 Marks)
(ii) Explain the objectives of computer security. (2 Marks)

Question forty one


a) Briefly explain the following
i) Kernel (2Marks)
ii)Thrashing (2Marks)
iii) Polling (2Marks)
iv) Stream (2Marks)
b) Define interrupts and explain the three sources of interrupts in OS. (6Marks)
c) Discuss five characteristics of modern operating systems. (5Marks)
d) Describe three Replacement policies for paged systems. (6Marks)
e) Describe five factors to consider when selecting a file design method. (5Marks)
Question forty two
a) Identify and explain any two fetch algorithms. (4Marks)
b) Discuss the services provided by the Operating System (7Marks)
c) Briefly explain the functions of O.S Kernel in process management (6Marks)
d) Explain the role the PCB plays during interrupt handling. (3Marks)
2
Question forty three
a) Give the states that a process can be in. (2Marks)
b) Briefly explain the reasons for process switch. (5Marks)
c) Discuss the principles of I/O software (5Marks)
d) Discuss four measures that can be undertaken to ensure security of the computer system.
(8Marks)
Question forty four
a) Explain the following memory allocation schemes
i. Contiguous allocation (2Marks)
ii. Segmentation (2Marks)
b) List four operations that are associated with files (4Marks)
c) Explain two approaches that can be used to store files in a disk pointing out advantages and
disadvantages of each. (8Marks)
d) Describe the information, which would be stored in a typical directory system pertaining to the
file
within the directory. (4Marks)
Question forty five
a) Explain four difficulties with Concurrency. (4Marks)
b) Discuss the conditions for Deadlock (8Marks)
c) Describe four strategies to overcome deadlock ones it is Detected. (8Marks)

Question forty six


a) Distinguish between the following pairs of terms:
i) Deadlock and Starvation [2 Marks]
ii) Kernel mode and User mode [2 Marks]
iii) Network and Distributed operating systems [2 Marks]
iv) Time sharing and Real time operating systems [2 Marks]
b) Outline four services provided by the operating system. [4 Marks]
c) With the aid of process transition diagrams discuss the following process state.
i. Two state process model [3 Marks]
ii. Three state process model [3 Marks]
iii. Five state process model [3 Marks]
2
d) With the aid of diagrams describe each of the following approaches of structuring operating
systems,
i. The layered approach [3 Marks]
ii. Monolithic approach [3 Marks]
iii. Client server approach [3 Marks]
Question forty seven
a) i. Define mutual exclusion [2 Marks]
ii. Discuss the mechanisms for achieving mutual exclusion. [6 Marks]
b) Most Modern Operating Systems support memory management with paging. Explain the
following.
i) Page fault [2 Marks]
ii) Replacement algorithms for paged system [6 Marks]
c) State four benefits of virtual memory [4 Marks]
Question Three
a) Discuss the objectives of I/O management. [4 Marks]
b) Identify four principles of input, output software. [4 Marks]
c) Distinguish between file protection and security. [2 Marks]
d) The manifestation of a process within the operating system is achieved by the Process Control
Block (PCB).
i) Explain the kinds of information maintained by the PCB [6 Marks]
ii) Explain the role the PCB plays during interrupt handling [4 Marks]
Question Four
a) Give a brief description of blocking, non-blocking and asynchronous I/O. [6 Marks]
b) Explain two approaches that can be used to store files in a disk pointing out advantages and
disadvantages of each. [6 Marks]
3
c) Describe the information, which would be stored in a typical directory system pertaining to the
file
within the directory [4 Marks]
d) Give four advantages of using directories. [4 Marks]
Question Five
a) Security goals of any computer system are decided by its security policies. Briefly explain three
computer security goals that can be set in an operating system. [6 Marks]
b) Identify five types of security threats to consider when designing and implementing any
operating
system. [5 Marks]
i) Distinguish between a Preemptive and a non-preemptive scheduling [4 Marks]
ii) Name one preemptive scheduling algorithm and one non-preemptive scheduling
algorithm. [2 Marks]
c) Explain briefly the difference between authorization and authentication [3 Marks]

QUESTION ONE (30 marks)


(a) Explain the generations of operating system (4 marks)
(b) Explain how to prevent circular wait condition in deadlock (2 marks)
(c) What is a kernel? What is the cause of kernel invocation (5 marks)
(d) Explain the booting process making use of the following terms; BIOS, POST,
CMOS, boot sector (5 marks)
(e) Explain the reasons that provides environment that allows process cooperation
(4 marks)
(f) Explain the structure of an operating system (5 marks)
(g) Explain lock and unlock operations of semaphore. (2 marks)
(h) List any three examples of internal priorities in priority scheduling (3 marks)
QUESTION TWO (20 marks)
(a) List and explain any two examples of operating system (2 marks)
(b) Suppose you have three processes P1, P2 and P2 having their execution times
16sec, 12sec and 8sec respectively. If the time slice is 4sec explain how many
rounds will it take the scheduler to complete the processes using Round Robin
algorithm (4 marks)
(c) Write short notes in the following
(i) RR Scheduling
(ii) Shortest Job First scheduling (4 marks)
(d) What does interface provide in the structure of operating system (2 marks)
(e) Give the difference between process and threads (4 marks)
(f) Explain any two scheduling criteria (4 marks)
QUESTION THREE (20 marks)
(a) Explain the role of operating system in device management (3 marks)
(b) What is file management? Explain any two file extensions (3 marks)
(c) Differentiate between preemptive and non-preemptive scheduling giving example
for each (4 marks)
(d) What is virtual memory? Explain paging and page fault (5 marks)
(e) Explain with the aid of a diagram the process states (5 marks)
Page 3 of 3
QUESTION FOUR (20 marks)
(a) Explain any two types of operating system (2 marks)
(b) Explain any two reasons that make UNIX a unique operating system (4 marks)
(c) List any two issues in memory management (2 marks)
(d) List Coffman’s (necessary) condition for deadlock (4 marks)
(e) Explain the following terms in scheduling
(i) Response time
(ii) Turn around time (4 marks)
(f) Explain an appropriate scheduling algorithm that can used in processes having
different lengths but same priorities (2 marks)
(g) Explain the following terms (i) Segmentation
(ii) Demand paging (2 marks)

QUESTION 1
a) Discuss the inconveniences that a user might face while interacting with a computer system,
which is without an operating system. (4Marks )
b) What are the benefits of multiprogramming? Explain any six. (5Marks)
c) Definitions for the following terms:
(i) Program
(ii) Process
(iii) Multiprogramming (3Marks)
d) What is the difference between true and concurrent server? (2Marks)
e) What are the benefits of parallel systems? Explain any three. (6Marks )
f) (i) What are the differences between segmentation and paging?
(ii) Explain an advantages and disadvantages of each. (4Marks)
g) Shown below is the workload for 5 jobs arriving at time zero in the order given below:-
Job Burst
1 10
2 29
33
47
5 12
Now considering SJF and round robin (RR) [with quantum = 10] algorithms for this set of jobs,
find out which algorithm would give the minimum average time. (6 Marks)
Page 3 of 4
PART B
QUESTION TWO
a) Differentiates between batch processing system and real time processing system.
(6Marks)
b) Differentiate between real time system and timesharing system. (4Marks )
c) Consider a system with a set of processes P1, P2, P3 and P4. Let their arrival times and CPU
burst times mentioned as below:-
Process Arrival time CPU Burst
time
P1 0 3
P2 1 6
P3 5 4
P4 6 2
Calculate all for FCFS, SJF and RR scheduling algorithms.
(i) Average turnaround time (3Marks )
(ii) Average waiting time. (3Marks )
(iii)Average throughput. (2Marks )
d) What is in a thread control block? (2Marks)
QUESTION 3
a) What is scheduling? What criteria affect the performance of various schedulers? Explain any
four.
(7Marks)
b) What is time slicing? How the time slicing duration affects the overall working of the
system? (4Mark )
c) Explain the following allocation algorithms with advantages and disadvantages.
i. First fit.
ii. Best fit
iii. Next fit. (6Marks)
d) How external fragmentation can be avoided. Explain with an example. (3Marks)
Page 4 of 4
QUESTION FOUR
a) Explain any three access modes for operation on a file. (3Marks)
b) (i) What do understand by file attributes? (2Marks)
(ii)Explain any three categories of file attributes? (3Marks)
c) (i) Explain SRT scheduling with example. (2Marks)
(ii) Give advantages and disadvantages of SRT (2Marks)
e) What are the four different objectives which must be considered in the design of scheduling
discipline? Explain. (4Marks)
f) What factors can lead to the degradation of the performance of round robin (RR) scheduling?
(4Marks)
QUESTION FIVE
a) What is meant by disk scheduling? Explain why disk scheduling is necessary. (4Marks )
b) consider a disk queue with request of I/O to block on cylinder
98, 183, 37, 122, 14, 124, 65, 67
If the disk head is initially at cylinder 53, then calculate total number of head movements using
following algorithms:
i. SCAN
ii. LOOK (6Marks )
c) (i) What is a deadlock situation. (2Marks)
(ii) Explain any four necessary conditions for a deadlock to occur. (4Marks)
d) How can we avoid deadlock situation? Justify your answer. (4Marks)

1. Define the term "operating system" (2 mks)


2. Explain any Two basic functions of an OS related to Process management (4 mks)
3. What is Virtual memory? How is this technique implemented? (2 mks)
4. Differentiate Internal fragmentation and External fragmentation. (4 mks)
5. Differentiate between the following as used in OS (8 mks)
- Device controller and device Driver
- System Call and system program
- monolithic Architecture and Microkernal Architecture
- paging and segmentation
6. Explain four features of a good password (6 mks)
7. Explain the four conditions for deadlock occurrence (6 mks)
8. Differentiate Long term scheduling and Short term scheduling (4 mks)
9. Describe two attributes of a file (4 mks)

1.(a)Define the term Operating System (1marks)


(b)State and explain three objectives of an Operating System (6marks)
(c)State and explain the five services provided by operating system to the Convenience of the users
(10marks)
(d)Define the following terms as used in the Operating system (4marks)
-kernel
-multiprogramming

2.(a)Define the following terms as used in process management (2marks)


-process control block
-process scheduling
(b)Differentiate between Turn Around Time and Response Time (2marks)

(c)A process goes through a series of discrete process [Link] the five states.
(3marks)
(d)Consider the following set of process with the length of CPU burst given in milliseconds.
Process Burst time
P1 12
p2 3
p3 5
p4 2
p5 6
Assume process arrive in the order P1,P2,P3,P4,P5 all at time 0.
[Link] three Gantt illustrating the execution of these processes using FCFS, preemptive),SJF(non
preemptive) and RR quantum=1. (6marks)

[Link] the turnaround time (TT) of each process for each of the alogarithms in (1)above
(3marks)
[Link] the waiting time for each job in the 3 alogarithms. (3marks)

QUESTION ONE [20 Marks]


(a) Explain briefly the following terms:
(i) Race condition (ii) Synchronization (iii) Semaphore ((iv) Deadlock (8 marks)
(b) Describe the three states a process can be in while in the system. (6 marks)
(c) What are the four necessary conditions for deadlock? (2 Marks)
(d) Describe the paging memory allocation scheme. What are its advantages and disadvantages
over
segmentation? (4 Marks)

QUESTION TWO [20 Marks]


a) Describe briefly four reasons for process termination. (4 Marks)
(b) What is a control structure that the operating system uses to keep the information of the
process context?
Give the pieces of information that are likely to be in this structure. (4 marks)
(c) (i) How does the OS implement the process abstraction? (2 marks)
(ii) Explain the difference between a process and a thread. (4 marks)
(d) (i) How do you define the User-Level Threads (ULT)? (3 Marks)
(ii) What are the Kernel activity for ULTs? (3 Marks
2

QUESTION THREE [20 Marks]


(a) Using the multiprocessing capability criteria, how do you decribe the differences between DOS,
NT, and
UNIX. (3 marks)
(b) (i) What are the stipulations of C2 level security? (4 Marks)
(c) (i) Explain any three of the six typical elements of a process image. (6 Marks)
(d) (i) Distinguish between scheduling and a scheduler. (4 marks)
(ii) What are local and global page replacements? (3 marks)

QUESTION FOUR [20 Marks]


(a) (i) Explain any two of the four popular multiprocessor thread-scheduling strategies. (4 Marks)
(ii) Describe four typical services provided by the operating systems. (4 Marks)
(iii) Discuss the two components that make up any I/O device. (4 marks)
(b) (i) Distinguish between security policies and mechanism. (2 marks)
(ii) Explain the principle of fragmentation. Discuss the two main types of fragmentation. (6 Marks)
QUESTION FIVE [20 Marks]
(c) (i) Describe the concept of virtual memory. (2 marks)
(ii) Distinguish between the FIFO and LRU replacement policy. (4 marks)
(d) (i) What is the definition of Critical Section (CS) and what is the requirement for the excecution
of CS?
(4 marks)
(ii)Describe in detail, the three types of solutions that address the critical section problem. (6
marks)
(iii) What are the drawbacks of software solutions to the critical section problem? And how does
the Semaphores
concept helps? (4 Marks)

(a) State four objectives of process scheduling in a computer system.(4marks)


(b) Discuss the following process scheduling algorithms
(i) Short job First (SJF).
(ii) Shortest job Remaining Next (SJRN)(6marks)
(c)Table 1 shows four process and their CPU burst times.
Process-------------- Arrival time----------CPU Burst
A-------------------- 0---------------------- 20
B-------------------- 1---------------------- 5
C-------------------- 2---------------------- 15
D-------------------- 3---------------------- 10
(i) Illustrate execution of the process using the round robin scheduling algorithm given that the
time slice is 4 units.(4marks)
(ii) Illustrate the execution of the process using the First come first served scheduling algorithm.
(2marks)
(iii) Evaluate the CPU performance based on the results obtained in (i) and (ii).(4marks)

2.(a) A large organization with a large warehouse would like to buy some computers for its staff
[Link] a computer expert,advicse on the most suitable type of computers to be purchased for
the following personnel:(justify your answer in each case).
(i) Secretaries.
(ii) Market-research executives.
(iii)A stores manager in charge of physically verifying stocks in the warehouse.
(iv) The company director for scheduling all his appointments and what-to-do-lists.
(v) A database administrator for storing all the data of the organization.(5marks)
(b) An entrepreneur would like to start a cybercafé that will include a business unit where
advertisements, brochures, letters and documents can be produced. The cybercafé will also support
video conferencing for all its clients.
(i) Explain five hardware devices that would be required for the successful implementation of the
cybercafé.(5marks)
(ii) Identify four types of software that would be required in the cybercafé giving a suitable example
in each case.(4marks)
(iii) Explain a suitable security mechanism that could be used to prevent network intrusion to the
cybercafé.(2marks)
(c)A large company is planning to network its computers with a provision for centralized access to
its data resources. Justifying your answer, identify two computer personnel who would be required
to achieve the company's objectives.(4marks)

3.(a) Explain four negative impacts of internet technology in an organization.(4marks)


(b) A company would like to install a reliable LAN with minimal cabling. The medium access
mechanism to be adopted will ensure that only one computer transmits data at any given time
successfully. With the aid of a sketch diagram, describe a suitable topology that could be used.
(6marks)
(c)A school would like to buy computers, Explain three types of operating systems that the school
can choose from, giving an example in each case.(6marks)
(d) Write the MS-DOS commands to perform the following tasks :
(i) Create a lotus 1 directory.
(ii) Change to the lotus 1 directory.
(iv) Copy lotus 1 program stored on a hard disk to a diskette.
(v) Return to the root directory.(4marks)

4. (a) Differentiate between device drivers and device controllers.(4marks)


(b) Input and output devices cannot be able to keep pace with the processor so that peaks and
troughs in 1/0 data rates needs to be smoothed to keep the processor working at an optimum
speed.
(i) Identify two techniques that can be used to improve on performance. (2marks)
(ii) Describe the techniques identified in (b) (i). (4marks)
(c)A disk has the following cylinder requests: 2, 15, 30,9,16 and 10 in that order. Given that the disk
arm is at position 14, describe the head movement using the following scheduling algorithms.
(i) FCFS.
(ii) Shortest Service Time First.
(iii) SCAN.(6marks)
(d) Describe four registers that are required during an interrupt. (4marks)

5. (a) With the aid of a diagram, describe the Five-state process model.(8marks).
(b) (i) Distinguish between semaphores and monitors as used in operating systems.(4marks)
(ii) Explain how deadlocks can be avoided using semaphores.(4marks)
(c)Describe the following terms as used in operating systems :
(i) Race condition.
(ii) Critical region.(4marks)

6.(a) A student wanted to install an application program that was stored in a compact disk which
did not have the Auto Run [Link] the procedure he would follow to install the program.
(4marks)
(b) As a copy typist was working on her computer,the mouse failed before she could complete her
[Link] the keyboard keys she would use to perform the following tasks:
(i) Move the cursor to the end of the line
(ii) Place data from a clipboard to a document.
(iv) Terminate an application that is not responding.(3marks)
(c)Explain two factors that should be considered when buying a new mouse to replace a faulty one.
(2marks)
(d) A doctor recently acquired a new computer system.
(i) State five safety guidelines that he should follow in order to avoid computer related injuries.
(5marks)
(ii) List six measures that the doctor should take to ensure that his computer is free from viruses.
(6marks)

7.(a) Direct Memory Access is used to enhance the performance of a computer. Using a diagram,
describe how this is achieved in an output/input operation.(5marks)
(b) Distinguish between paging and segmentation as applied in memory management.(4marks)
(c) A computer system has two types of clocks.
(i) State five roles of the clock software in a computer system.(5marks)
(ii) Describe the two modes of operation of a hardware clock.(6marks)

8.(a) Distinguish between a file and a root directory.(4marks)


(b) A teacher needs a file to store students information. The file will be updated every term. The
teacher will have only access rights to write. Describe four operations that can be performed on the
file.(4marks)
(c)Distinguish between absolute and relative paths names as applied in operating systems.
(4marks)
(d) Describe four protection mechanisms that are used by operating systems to ensure security.(8
(d) Define the following terms regarding the operating systems:
[8 marks]
(i) Utilities.
(ii) Kernel.
(iii) Spooling.
(iv) Interrupts.

END

You might also like