You are on page 1of 19

2.7.

1 Scheduling Criteria

Q. Discuss various scheduling criteria. MU


.
May 16, May 19, 5 Marks
aIn multiprogramming. many programs remain in memory atthe same time. Processes cary out 1/0 operations
while performing the execution.
S i n c e I/0 operations generally time
consume more
to. accomplish with compare to CPU instructions,
multiprogramming systems hand over the CPU to another ready process whenever a any process invokes an
I/0
operation.

TechKnowledge
PUDIIC ations
Operauing System (MUJ

Snort term scheduler allocates the processes to CPU as per some policy called as scheduingaigorithms.
CPU busy all the time.
ne man aim
of the scheduling is to improve performance by keeping
Criteria for the performance evaluation ofthe scheduling strategy is:

o CPU Utilization: It is amount of time CPU remains busy.


o Throughput: Number of jobs processed per unit time.
o Turnaround time : Time elapsed between submission of job and completion of its execution.
o Waiting time: Processes waits in ready queue to get CPU. Sum of times spent in ready queue is waiting time.

o Response Time : Time from submission tillthefirst response is produced.


o Fairness: Every process should get fair share ofthe CPU time.
Following pairs ofscheduling criteria conflict in certain settings:
a. CPU utilization and response time: CPU utilization is increased if the overheads associated with context

switching is minimized. The context switching overheads could be lowered by performing context switches
infrequently. This could, however, result in increasing the response time for processes.
turnaround time is minimized by
b. Average turnaround time and maximum waiting time: Average
executing the shortest tasks first. Such a scheduling policy could, however, starve long-running tasks and

thereby increase their waiting time.


2.8.2 Difference between Process and Thread

Q. Differentiate the Process vs Thread


MU-May 16,5 Marks

Sr. No Parameters Process Thread


1. Definition Program in execution called as Thread is part of process. It is also
process. It is heavy weight process called as light weight process
2 Context Switch Process context switch takes more Thread context switch takes less time
time as compared to thread context as compared to process context switch
switch because it needs interface of because it needs only interrupt to
operating system. kernel only.
3. Creation New Process creation takes more timne New thread creation takes less time as
as compared to newthread creation. Compared tonew process creation.
4. Termination New Process termination takes more New thread termination takes less
time as compared to new thread time as compared to new process
termination. termination.
5. Execution Each process executes the same code All threads can share same set of open
but has its own memory and file files, child processes.
resources.

6. Implementation If implementation is process based, In multi-threaded server


then blocking of one process cause the implementation, if one thread is
blocking of other server process until blocked and waiting, second thread in
the first process unblocked and these the same process could execute.
are not allowed to execute until
blocked processis unblocked.
7. Resources Multiple redundant processes use With compare to multiple redundant
more resources than multiple processes, multiple threaded

threaded process. processes use fewer resources.


8. Address Space Context switch flushes the MMU (TLB) No need to flush TLB as address space
registers as address space of process remains same after context switch
changes. because threads belong to the same
procesS.
2.6.2 Types of Scheduling
shown in Fig. 2.6.3. Types of scheduling
Two types of scheduling algorithms are

that
algorithmns
1. Non-Preemptive : Non-preemptive algorithms are designed so

CPU, it does not free CPU until it 1. Non-Preemptive


once a process is allocated to
completes itsexecution.
2. Preemptive
22. Preemptive : Preemptive algorithms allow taking away CPU from
arrives i the
process during execution. If highest priority process
is allocated Fig. 2.6.3: Types ofschedul
system, CPU from currently executing low priority process
to it. It ensures that always highest priority process will
be executing.
1.6.6 Difference between Monolithic and Microkernel
la Differentiate beteen monolithic and microkernel structure of OS.
MU -June 15, Nov. 15, May 19, 5/10
Marks
Microkernel
Monolithic kernel
In microkernel, set of modules for managing the
If virtually entire operating system code is executed
hardware is kept which can
uniformly well be in kernel mode, then it is a monolithic program that
executed in user mode. A small microkernel contains in
runs a single address space
only code that must execute in kernel mode. It is the
second part of the operating system.

There is separate address space for user services and


There is same address space for user services and
kernel services.
kernel services

Microkernel size is smaller than monolithic kernel. It has a larger size compared to microkernel
Execution speed is slower than monolithic kernel. Execution speed is faster than microkernel.
It is more flexible. Any module can be replaced. It is not flexible as compared to microkernel. Its
component cannot be changed, without doing a total
shutdowm and perhaps even a full recompilation and
reinstallation.

Crash of one service does not affect working of other After crash of service complete operating system
part of microkernel. fails.
In microkernel, communication is through message Kernel calls the function directly.
passing

Performance degradation due to context switching Monolithic operating systems have drawbacks from
and communication overhead between different the viewpoint of openness, software
engineering,
modules. reliability, or maintainability. It has lack of flexibility
and having huge size.
Operating System Overview
Operating System (MU) 1-20
The interface calls that operating the system
between OS and user
to by
defined the set of system
OiTers. System
em callcalls
is the
make
call
un ththe operating is
for programs
programs svstem definea
Derform some task on behalf of the user's program.
Dy

ererore system calls make stem.


up the interface between processes and the operau6
The system calls are functions used the system call is
in the kernel itself. From programmer's point of view, a
normal C function call.
D u e to system call, the code is executed in the the process
kernel that there must be a mechanism to change
mode from user mode to
kernel mode.
so 1

first Operating system, applications do not have direct access to the computer hardware. Applications
user
request to the kernel to
get hardware access and access to computer resources.
During execution when application invokes a svstem call, it is interrupted and the system switches to Kernel
space. The kernel then saves the process execution context of
call. mterrupted prpces and determines purpose or the

T h e kernel warily makes sure tHat the_request is valid and that the process invoking the system calls has
sufficient privilege. Some of the
system calls canqnlylbe invoked by a user with super user privilege.
OIf the whole thing is fine, the kernel processe_ the request in kernel mode and can access the device drivers in
charge of conttelling the hardwaye. The data of the calling process can be read and modified by kernel, as it has
access to memory
in úser space
OBut, it will not execute any cqde from a user application, for clear security reasons.
DWhen the kernel finishes the processing of request, it restores the process execution context that was saved
when the system call was invoked.
1-22 Operating System
Operating System (MU)
because those methods mit sthe
do not limit Overie
method,
S o m e operating systems favor
the block or stack
number Op
length of parameters being passed.

1.9 Types of System Calls

any five system calls in detail.


MU-June 15, Nov. 15, Dec. 18,6Maark
Q. Explain
1.9.1.
categorized in five groups. These are shown Fig.
in
System calls are
******

Types of System Calis

***

1. Process contro
www.x RINKNRRRKEAKAYAAA WSOR

2. Device manipulation
2.
3. Communications
******ww*******w w w.wwewwwrwermerm wwwawn

4. File manipulation
www.ww******* *********
wwww***w*******|
3
5. Information maintenance

Fig. 1.9.1: Types of system calls

Sr. No. Group Examples


1. Process control end, abort, load, execute, create process, terminate process, get process attributes,
process attributes, wait for time, wait event, signal event, allocate and free
memory
2. File manipulation create file, delete file, open, close, read, write, reposition, get file attributes, ser
attributes
3. Device request device, release device, read, write, reposition, get device attributes, set device
manipulation attributes, logically attach or detach devices
4. Information get time or date, set time
date, get system data, set system data, get
or
file,
maintenance process,
device attributes, set process, file, or device attributes
5. Communications create, delete communication connection, send, receive ges,
messages, transfer status|
information, attach or detach remote devices.
Some Examples of System Calls

1. Open
Definition:An operating system acts as an interface between the user and hardware of the computer and also controls

the execution of application programs.

Operating system isalsocalled asresource manager.


All above OS like UNIX, Windows are not real time OS.

1.5 Operating System Services

o, Explain services provided by operating system.


MU May 16,5 Marks
The Fig. 1.5.1 shows six services provided by operating system for efficient execution of users
make convenience to use computer system:
application and to

Operating System
Servicess
w..ww
ww*wwwA
wwwww NAAAMWN

1, User Interface
********
****

2. Program Execution
wwwwwwwwwwwwwwwwwwwwwwwm
*** ****

3. 1/O Operations
********

4 . File System Manipulation


www.wwwwwww
* wwww.w****wwwwwww.********* ***

5. Communications
wwwwwwww monwwe awewwwww
******* *wwwwww A

6. Error Detection

Fig. 1.5.1:Operating system services

Techub::tKnomledgë
aionS
Operating System (MU)

1. User Interface

essential and all operating systems


provide it.
User interface is interface or graphical
user interface on

command-line
with the operating system through
Users either interface command.
executes next user-specified
GUI. Command interpreter
intertace.
as an
window and menu system
A GUI offers the user a mouse-based

2. Program Execution

environment to run users programs efficiently.


operating system provides
an
The system ensuring
execution are provided by operating
needed to the programs to complete
The resources

optimum utilization of computer system.


etc functions are
allocation and scheduling, multitasking
allocation and deal location, processor
Memory
performed by operating system.
these rights.
User program does not given
The operating system has all rights of r e s o u r c e management.

3. 1/0 0perations
without taking any input.
This involves the use
of 1/0. During
OEach program requires cannot produce output
output.
perform I/0 operations for input
or
execution, program requires to
in three ways i.e. programmed I/0,
state. 1/0 can be performed
Until 1/0 is completed, program goes in waiting

Interrupts driven and 1/0 using DMA.


I/0
by operating system from
users.
hidden
The underlying hardware for the 1/0 is
this service to
execute the user program. Operating system provides
These I/0 operations make it convenient to
user program for efficient execution.

4. File System Manipulation


the output. The input can be read from the files and produced
Program takes input, processes it and produces
output again can be written into the files.
stored secondary storage devices and
the operating system. All files are on
OThis service is provided by
manipulated in main memory.

the task
OThe user does not have to worry about secondary storage management. Operating system accomplishes
command specified by user.
of reading from files or writing into the files as per the
The
Although the user level programs canprovide these services, it is better to keep it with operating system.
execution speed is fundamental to I/0 operations.
reason behind this is that, program

5. Communications

communicates with each other. If communicating processes are running on different


D Cooperating processes
machines then messages
are exchanged among them and they gets transfer through network.

TechKnouledge
ubiic ations
Operating system (MU) 1-9 Operating System Overview

This communication can be realized by making the use of user programs by customizing it to the hardware that
facilitates in transmission of the message.

Customization of the user programs can be done by means of offering the service interface to operating system to
realize communication among processes in distributed system.

Iu this way the communication service will be provided by operating system and user programs from will be
free from taking care of communications.

6. Error Detection

a In order to prevent the entire system from malfunctioning, the operating system continually keeps watch on the
system for detecting the errors.

User programs kept free from such error detection to improve the performance.
On the contrary, if this right would have been kept with user programs, most of the user
program would have
wasted time in error detection and actual work would be minimized
resulting in performance degradation.
Operating system needs to carry out complex tasks during the process of error detection.
aSuch task comprises deal location of many resources such as processor,
memory etc. If these tasks are again kept
with user programs, then it may disturb the normal
operation of operating system.
2.3 Process States

Q. Draw process state transition diagram. MU Dec.14, 6 Marks


Q. Explain various process states with diagram.
MU- Dec.18, 5 Marks
Q. Write short notes on Process state transition
MU-May 19, 10 Marks
Q. Draw process state diagram and explain the following states:
. New 2. Ready 3. Running 4. Wait 5. Suspended ready 6. Suspended wait MU- Dec. 19,5 Marks
During execution, process changes its state. Process state shows the current activity of the process. Process state
contains five states.

Each process remains in one of these five states. There is a queue associated with each state of the process.
Process resides
onthat queue as per the state in which it resides.
Tech Knowledge
Pubilc ationS
Process & Process Schedulino
2-3
Operating System (MU)
1. New state

The new process being created.

2. Ready state
to it.
it is waiting for CPU being assined
A process is ready to run but

3. Executing state
it and it is executing,
CPU is allocated to
state if currently
A process is said to be in running

4Waiting(blocked) state
event to happen such as 1/0 completion. Process
execution because it
is waiting for
A process can't continue
the
external event happens.
is able to run when some

5. Terminated state

execution.
The process has completed
is shown in Fig 2.3.1.
The process state transition diagram

Terminated
New

/Finished
Submitted Interrupt
Executing
Ready
Dispatched for execution
I/O or event
VO or event completion

Waiting

diagram
Fig. 2.3.1: Process state transition

remains in new state. After the process admitted


for execution, it goes in read
W h e n the process is created, it
wait in the ready queue. Scheduler dispatches the ready process for
execution ie
state. A process in this state,
CPU is now allocated to the process.

from executing
OWhen CPU is executing the process, it is in executing state. After context switch, process goes
initiates an I/0 operation before its allotted time expires, the executing
proces
ready state. If executing process
voluntarily give up the CPU.

I n this case process transit from executing to waiting state. When the external event for which a proces
sitto
waiting happens, process transit from waiting to ready state. When process finishes the execution, it trau

terminated state.

Tech ANONI
PubilCa
2.5 Process Control Block (PCB)

MU Dec. 14, 5 Marks


Q. Explainrole of process control block.
MU Dec. 16,5 Marks
Q. Write note on : Process Control Block.
by the operating
its process control block (PCB). PCB is the data structure used
Any process is identified by
system to keep track on the processes.
PCB for each
All the information associated with process is kept in process control block. There is separate

process
which are in the same
Traffic controller module keeps track on the status of the processes. PCB's of the processes
name to the list such as ready
list.
state (ready, executing, waiting etc) are linked together giving specific
a

linked together in chain waiting


Tf many processes wait for the same device, then PCBs of all these processes are
for that device.

OIfdevice becomes free then traffic controller checks the PCB chain to see if any process is waiting for the device.
If the processes are available in that device chain, then again it is placed back to ready state to request that device

again.

A typical process control block is shown in Fig. 2.5.1.

Pointer Current State

Process ID

Priority
Program counter
Registers
Accounting
Memory allocations
Eventinformation
List of openfiles
Fig. 2.5.1: Process control block

Tech Knowledge
PUb'iCationS
Operating System (MU) 2-6 Process& Process Scheduling

Pointer: This field points to other process's PCB. The scheduling list is maintained by pointer.
1.
2. Current state : Currently process can be in any of the state from new, ready, executing, waiting etc as
2.
described above.

3. Process ID : ldentification number of the process. Operating system assign this number to processto
distinguish it from other processes.

4, Priority: Difterent process can have different priority. Priority field indicate the priority ofthe process.

5. Program counter: Atter context switch, CPU is given to other process. When turn of the previously

executing process comes, again CPU gets allocated to it. Program counter contains address of the instruction
from which execution resumes after context switch.

6. Registers : It includes general purpose register, index registers, stack pointers and accumulators etc
number of register and type of register differs as per the architecture of computer. The state information
stored after interrupt is again used by the process to resume the execution.

7. Accounting : Information for calculating the process's priority relative to other processes. This may include
accounting information about resource use so far. It also includes amount of CPU time and real time used,
time limits, process numbers and so on.

8. Memory allocation: This information may include the value of base and limit regíster. It includes paging
segmentation related information depending on the memory system used. Address space allocated to the
process etc.

9. Event information: For a process in the blocked state this field contains information concerning the event
for which the process is waiting.

10. List of open files : Files opened by the process.

After creation of the process, hardware registers and flags are set as per the details supplied by loaders or
linkers.
At any time the process is blocked, the processor register's content are generally placed on the stack and the
pointer to the respective stack frame is stored in the PCB. In this fashion, the hardware state can be restored
when the process is scheduled and resume execution again.

2.6 Scheduling

Q. Discuss various types of scheduler, MU Dec 18,5 Marks


2.6.1 Scheduling Queues and Schedulers

aSystem places all the entered processes in job queue. All the processes in the system reside in job queue.

aWhen processes are ready for the execution and wait for CPU, they kept in ready queue.

Apart from the job queue, the operating system also has other queues.
Whe processes wait for particular device, they are kept in respective devices queue.

Tach Knowledge
Kernel tnreaas aregenerauy requires more ume w ereaeau uiauage uar a

2.10 Concept of Multithreading

Q. Discuss the importance of"Multithreading". MU -Dec. 19, 2 Marks


aIn operating system that support multithreading, process can consist of many threads. These threads run in
parallel improving the applicationperformance.
Each such thread has its own CPU state and stack, but they share the address space of the process and the
environment
a
Considering
threadscan
the advantages
be implemented.
of user level and kernel level threads, a hybrid threading model using both types of
Tech Knowledge
PuD'iCa:iars
Operating System (MU) 2-19 Process& Process Schedul
The Solaris operating system supports this hybrid model.

O In this implementation, all the thread management functions are carried out by user level
space. So operations on thread do not require kernel intervention.
thread
package at usel
package.

aThe advantage of hybrid model of the threads is that, if the


applications are multithreaded then it can
advantage of multiple CPUs if they are available. Other threads can ak
can continue to make progress
blocks one thread in a system function.
even if the ke
erne
2.10.1 Three Types of Multithreading Models

Three types of
multithreading models

1. One to one

2. Many to one

3. Many to many

Fig. 2.10.1: Types of multithreading model


1. One to one model
In this model
relationship between user level thread and kernel level thread is one to one. It means
mapping of a single user-level thread to a that there is
single kernel-level thread.
Because of such type of relationship multiple threads executes in parallel leading to more
However, since it is needed to create concurrency.
kernel thread for every new creation of
performance will be degraded. user thread. So
application
Windows series and Linux
operating
thread count. OS/2, Windows NT and systems try
to minimize this
problem by restricting the expansion
windows 2000 use one to one of the
relationship model.
User level threads

8 Kenel level threads


Fig. 2.10.2: One to one model
2. Many to one model
OIn this model
relationship between user level thread and
kernel level
mapping of many user-level threads to a thread is many to one. It means
single kernel-level thread. that there
aIn this model
management is done in user
space. When
process gets blocked. one thread makes a
system call for blocking, the
At a time only one thread
en
can access the Kernel thread
on multiple processors. at a time, so
many other threads cannot execute in rallel
paia

Tech Knowledge
PubIICa tiov
Operating System (MU) 2-20 Process & Process Scheduling
Therefore concurrent execution of threads cannot be achicved. This type of relationship facilitates an effective
context-switching environment, easily implementable even on simple kernels with no thread support
User level threads

Kernel level threads

Fig. 2.10.3 Many to one model

3. Many to Many Model

a Many to many association exist between user level thread and kernel level thread in this model.
a It means that more number of user-level threads are allied to equal or less number of kernel-level threads.
aThe necessity of altering code in both kernel and user spaces leads to a level of complexity not present in the one
tone and many to one
model
O Like many-to-one model, this model offers an efficient context-switching environment as it
calls. repel from system
The keen complexity offers the potential for priority inversion and suboptimal scheduling with minimum
coordination between the user and kernel schedulers.

User level threads

K) Kernel level threads


Fig. 2.10.4: Many to Many model
2.11 Examnles on LIninn
1.1 Introduction to Operating System

Q. What is operating system? MU-Dec. 14, June 15, Nov. 15, Dec. 18, 2 Marks
Q. Discuss Operating System as a Resource Manager. MU -Dec.19, 5 Marks

Q. Define Operating System. MU - May 19, 2 Marks

A n operating system is system software which manages, operates and communicates with the computer
hardware and software.

T o complete the execution user program need many resources.


The main Job of the operating system is to provide resources and services to the user program. So without
operating system, a computer would be useless.

Definition :An operating system acts as an interface between the user and hardware of the computer and also controls
the execution of application programs.

Operating system is alsocalled as resource manager.


1.1.1 Need of Operating System
Basically operating systems perform tasks, for example identifying input from the input devices such as
keyboard, mouse etc and sending output to the output devices such as monitor, printer etc and keeping track of
files and directories on the disk, and controlling peripheral devices such as secondary storage devices, printers,
Scanners, audio mixer.

The heart of a computer system is a processing unit called CPU.

User's program should get the processing unit to complete the execution and computer system should offer the
service to allocate processing unit to users program.

a The operating system allocates memory to user program as per need. In the same way, user programs interact
with the other user programs through devices like key board, or a mouse or even a joy stick.

You might also like