0% found this document useful (0 votes)
2 views42 pages

Module 1

Introduction to Operating system

Uploaded by

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

Module 1

Introduction to Operating system

Uploaded by

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

 A computer system has many resources (hardware and software), which may be require to complete

a task.
 Operating System is a system software that acts as an intermediary between a user and Computer
Hardware to enable convenient usage of the system and efficient utilization of resources.
 The commonly required resources are input/output devices, memory, file storage space, CPU etc.
 The operating system acts as a manager of the above resources and allocates them to specific
programs and users, whenever necessary to perform a particular task.
 Therefore operating system is the resource manager i.e. it can manage the resource of a computer
system internally.
 The resources are processor, memory, files, and I/O devices. In simple terms, an operating
system is the interface between the user and the machine
Architecture of an Operating System

Operating system is the most important program that runs on a computer. OS is considered as the
backbone of a computer, managing both software and hardware resources.
 They are responsible for everything from the control and allocation of memory to recognizing input
from external devices and transmitting output to computer displays.
 They also manage files on computer hard drives and control peripherals, like printers and scanners.
 Operating systems monitor different programs and users, making sure everything runs
smoothly,without interference, despite the fact that numerous devices and programs are used
simultaneously.
 An operating system also has a vital role to play in security. Its job includes preventing unauthorized
users from accessing the computer system.

GOALS OF OPERATING SYSTEM :


 Execute user programs and make solving user problems easier.
 Make the computer system convenient to use.
 Use the computer hardware in an efficient manner.
FUNCTIONS OF OPERATING SYSTEM / SYSTEM COMPONENTS:
Main Memory Management
 Processor Management
 Device Management
 File Management
 I/O System Management
 Secondary Management
 Networking
 Protection System
 Command Interpreter System

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 accessed directly by the CPU.

 ACTIVITIES for memory management :

o Keeps tracks of primary memory, i.e., what part of it are in use by whom, what part is not in use.
o In multiprogramming, the OS decides which process will get memory when and how much.
o Allocates the memory when a process requests it to do so.
o De-allocates the memory when a process no longer needs it or has been terminated.

PROCESSOR MANAGEMENT:
 In multiprogramming environment, the OS decides which process gets the processor when and for
how much time. This function is called process scheduling.
 ACTIVITIES of processor management
o Keeps tracks of processor and status of process. The program responsible for this task is known as
traffic controller.
o Allocates the processor (CPU) to a process.
o De-allocates processor when a process is no longer required.

DEVICE MANAGEMENT:
 An Operating System manages device communication via their respective drivers.
 ACTIVITIES of device management
o Keeps tracks of all devices. Program responsible for this task is known as the I/O controller.
o Decides which process gets the device when and for how much time.
o Allocates the device in the efficient way.
o 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.
 ACTIVITIES of file management
o Keeps track of information, location, uses, status etc. The collective facilities are often known as file
system.
o Decides who gets the resources.
o Allocates the resources.
o De-allocates the resources

I/O SYSTEM MANAGEMENT:


 OS hides the peculiarities of specific hardware devices from the user.
 It consists of
o A memory management component that includes buffering, caching and spooling.
o A general device-driver interface
o Drivers for specific hardware devices.
o Only the device driver knows the peculiarities of the specific device to which it is assigned.

SECONDARY STORAGE MANAGEMENT:


 The main purpose of a computer system is to execute programs. These programs, with the data they
access ,must be in main memory, or primary storage.
 Systems have several levels of storage, including primary storage, secondary storage and cache
storage.

Since main memory (primary storage) is volatile and too small to accommodate all data and programs
permanently, the computer system must provide secondary storage to back up main memory.
 Most modern computer systems use disks as the principle on-line storage medium, for both programs
and data.
 ACTIVITIES are,
o Free-space management (paging/swapping)
o Storage allocation (what data goes where on the disk)
o Disk scheduling (Scheduling the requests for memory access).

NETWORKING:
 A distributed systems are a collection of processors that do not share memory, peripheral devices, or
a clock.
 The processors in a distributed system vary in size and function. They may include small
processors,workstations, minicomputers and large, general-purpose computer systems.
 The processors in the system are connected through a communication-network ,which are configured
in a number of different ways i.e.., Communication takes place using a [Link] network may be
fully or partially connected .
 The communication-network design must consider routing and connection strategies, and the
problems of contention and security.
 A distributed system provides user access to various system resources.
 Access to a shared resource allows:
o Computation Speed-up
o Increased functionality
o Increased data availability
o Enhanced reliabilit………..y

PROTECTION SYSTEM:
 If a computer system has multiple users and allows the concurrent execution of multiple processes,
then the various processes must be protected from one another's activities.
 Protection refers to mechanism for controlling the access of programs, files, memory segments,
processes(CPU) only by the users who have gained proper authorization from the OS.
 The protection mechanism must:

 Distinguish between authorized and unauthorized usage.


o Specify the controls to be imposed.
o Provide a means of enforcement.
COMMAND INTERPRETER SYSTEM:
 A command interpreter is one of the important system programs for an OS. It is an interface of the
operating system with the user. The user gives commands, which are executed by Operating system
(usually by turning them into system calls).
 The main function of a command interpreter is to get and execute the next user specified command.
 Many commands are given to the operating system by control statements which deal with:
o process creation and management
o I/O handling
o secondary-storage management
o main-memory management
o file-system access
o protection
o networking
o

Generations of OS

CLASSIFICATION OF OPERATING SYSTEM:


 Multi-user OS:
o Allows two or more users to run programs at the same time. This type of operating system may be
used for just a few people or hundreds of them. In fact, there are some operating systems that permit
hundreds or even thousands of concurrent users.
 Multiprocessing OS:
o Support a program to run on more than one central processing unit (CPU) at a time. This can come
in very handy in some work environments, at schools, and even for some home-computing situations.
 Multitasking OS :
o Allows to run more than one program at a time.
 Multi threading OS:
o Allows different parts of a single program to run concurrently (simultaneously or at the same time)

Real time OS:


o These are designed to allow computers to process and respond to input instantly. Usually, general
purpose operating systems, such as disk operating system (DOS), are not considered real time, as they
may require seconds or minutes to respond to input. Real-time operating systems are typically used
when computers must react to the consistent input of information without delay.
o General-purpose operating systems, such as DOS and UNIX, are not real-time. Today’s operating
systems tend to have graphical user interfaces(GUIs) that employ pointing devices for input. A mouse is
an example of such a pointing device, as is a stylus. Commonly used operating systems for IBM-
compatible personal computers include Microsoft Windows, Linux, and Unix variations. For Macintosh
computers, Mac OS X, Linux, BSD, and some Windows variants are commonly used.

.
Batch-processing operating system was very popular in the 1970s. In batch operating system the
jobs were performed in batches. This means Jobs having similar requirements are grouped and
executed as a group to speed up processing. Users using batch operating systems do not interact
with the computer directly. Each user prepares their job using an offline device for example a
punch card and submits it to the computer operator. Once the programmers have left their
programs with the operator, they sort the programs with similar needs into batches.

Batch-O S
SYSTEM CALLS:

 System calls provide the interface between a process and the operating system.
 These calls are generally available as assembly-language instructions.
 Some systems also allow to make system calls from a high level language, such as C, C++and Perl
(have been defined to replace assembly language for systems programming). As an example of how
system calls are used,consider writing a simple program to read data from one file and to copy them to
another file.
 The first input that the program will need is the names of the two files:
o The input file
o The output file
 Once the two file names are obtained, the program must open the input file and create the output file.
 Each of these operations requires another system call and may encounter possible error conditions.

o When the program tries to open the file, it may find that no file of that name exists or that the file is
protected against access.
 If the input file exists, then we must create a new output file.
 We may find an output file with the same name.
o This situation may cause the program to abort (a system call), or
o We may delete the existing file (another system call).
 In an interactive system another option is to ask the user ( a sequence of system calls to output the
prompting message and to read response from the keyboard) whether to replace the existing file or to
abort the program.

2l;’

Now that both the files are setup, we enter a loop that reads from the input file (a system call)and writes
to the output file (another system call).
 Each read and write must return status information regarding various possible error conditions.
o On input,
 the program may find that the end of file has been reached, or
 that a hardware failure occurred in the read (such as a parity error).
o On output,
 Various errors may occur, depending on the output device (such as no more disk space, physical end
of tape, printer out of paper).
 Finally, after the entire file is copied, The program may close both files (another system call), writes a
message to the console(more system calls), and finally terminates normal (the final system call).

 System calls occur in different ways, depending on the computer in use.

 Three general methods are used to pass parameters between a running program and the operating
system.
o Simplest approach is to pass parameters in registers.

o Store the parameters in a table in memory, and the table address is passed as a parameter in a register
(in the cases where parameters are more than registers).
o Push (store) the parameters onto the stack by the program, and pop off the stack by operating system.

TYPES OF SYSTEM CALLS


 System calls can be grouped roughly in to five categories:
o Process control:load, execute, abort, end, create process, terminate process, get process attributes,
set process attributes, allocate and free memory, wait event, signal event.
File management :create file, delete file, open, close, read, write,reposition, get file attribute,set
fileattributes.
o Device management :request device, release device, read, reposition,write,get device
attributes,setdevice attributes, logically attach or detach device.
o Information maintenance :get time and date, set time and date, get system data, set system data,
get process file or device attributes, set process file or device attributes.
o Communications :create, close communication connection, send, receive messages, transfer status
information, attach or detach remote devices. Communication may take place using:
  message passing model or
  shared memory model
SYSTEM STRUCTURE:
 A system as large and complex as a modern operating system must be engineered carefully if it is to
function properly and be modified easily.
 A common approach is to partition the task into small components rather than have one monolithic
system.
 There are four different structures that have shown in this document in order to get some idea of the
spectrum of possibilities.
 These are by no means exhaustive, but they give an idea of some designs that have been tried in
practice.

SIMPLE STRUCTURE:
 Many commercial systems do not have well-defined structures. Frequently,such operating systems
started as small, simple, and limited systems and then grew beyond their original scope.
 MS-DOS is an example of such a system. It was originally designed and implemented by a few
people who had no idea that it would become so popular.
MS-DOS:

MS DOS LAYER STRUCTURE


 It was written to provide the most functionality in the least space(because of the limited hardware on
which it ran)
 So it was not divided into modules carefully.
 MS-DOS has some structure, its interfaces and levels of functionality are not well separated

UNIX:
 UNIX is the another system limited by hardware functionality. It consists of two separable parts

o System programs
o Kernel

UNIX System Structures


The Kernel :
 The kernel is further separated into a series of interfaces and device drivers, which have been added
and expanded over the years as UNIX has evolved.
 Everything below the system call interface and above the physical hardware is the kernel.
 The kernel provides the file system, CPU scheduling,memory management, and other operating-
system functions through system calls.
 Taken in sum, that is an enormous amount of functionality to be combined into one level
 New versions of UNIX are designed to use more advanced hardware.
 With proper hardware support, operating systems can be broken into pieces that are smaller and more
appropriate than those allowed by the original MS-DOS or UNIX systems.
 The operating system can then retain much greater control over the computer and over the
applications that make use of that computer.
 Implementers have more freedom in changing the inner workings of the system and in creating
modular operating systems.

LAYERED APPROACH:
 A system can be made modular in many ways. One method is the layered approach, in which the
operating system is broken up into a number of layers (levels), each built on top of lower layers.
 The bottom layer (layer 0) is the hardware; the highest (layer N) is the user interface as shownin
below. With modularity, layers are selected such that each uses functions (operations) and services of
only lower-level layers.
Fig:1.7 A Layered Operating System

 A layered design was first used in the operating system. Its six layers are as follows:
LAYER 5 User Programs
LAYER 4 Buffering for Input and
Output
LAYER 3 Operator Console Device
Driver
LAYER 2 Memory Management
LAYER 1 CPU Scheduling
LAYER 0 Hardware

An operating-system layer is an implementation of an abstract object made up of data, and ofthe


operations that can manipulate those data.
 A typical operating-system layer—say, layer M consists of data structures and a set of routinesthat
can be invoked by higher-level layers. Layer M, in turn, can invoke operations on lowerlevellayers.

Fig:1.8 A typical Operating System Layer


 ADVANTAGE :
o The main advantage of the layered approach is modularity (simplicity of construction and
debugging). The layers are selected so that each uses functions (operations) and services of only lower-
level layers.
 DISADVANTAGE :
o The major difficulty with the layered approach involves appropriately defining the various layers.
Because a layer can use only lower-level layers, careful planning is necessary.
o A final problem with layered implementations is that they tend to be less efficient than other types.
o Fewer layers with more functionality are being designed, providing most of the advantages of
modularized code while avoiding the difficult problems of laver definition and interaction.

OS/2 Layer Structure


KERNELS:

Working of Kernel
The kernel is the first part of the OS loaded into memory during boot, and it stays resident while the system is
running.
It operates in a privileged mode (kernel mode), separate from user mode for applications; user apps can’t
directly access hardware or critical resources.
Applications make requests to the kernel via system calls (or software interrupts). The kernel handles these by
switching from user mode to kernel mode.
Kernel executes the requested operation (e.g. file I/O, process creation, memory allocation).
On completion, kernel returns result (or error) to user space.
Kernel does context switching as needed (scheduler picks next process/thread) to allow multitasking.

The fundamental part of an Operating system


 Responsible for providing secure access to the machine’s hardware for various programs
 Responsible for deciding when and how long a program can use a certain hardware.
 TYPES:
o Monolithic kernel
o Micro kernel
o Hybrid kernels
o Nano kernels
o Exo kernels

MICRO KERNELS:
 This method structures the operating system by removing all non essential components from the
kernel and implementing them as system and user-level programs i.e., moves as much from the kernel
into ―user‖ space which results is a smaller kernel.
 Micro kernels typically provide minimal process and memory management, in addition to a
communication facility.
 The main function of the micro kernel is to provide a communication facility between the client
program and the various services that are also running in user space.
 Communication takes place between user modules using message passing. They communicate
indirectly by exchanging messages with the micro kernel.
 One benefit of the micro kernel approach is ease of extending the operating system. All new services
are added to user space and consequently do not require modification of the kernel.
 The micro kernel also provides more security and reliability, since most services are running as user
—rather than kernel—processes.
 This micro kernel is a smaller kernel, which allows a only fewer changes in the operating system.
 BENEFITS :
o Easier to extend a microkernel
o Easier to port the operating system to new architectures
o More reliable (less code is running in kernel mode)
o More secure
 DRAWBACKS:
o Microkernels can suffer from performance decreases due to increased system function overhead.
Exokernel
An Exokernel OS design pushes the boundaries of minimalism. Applications are given
direct access to hardware resources, allowing them to manage resources and make
decisions that the kernel previously made.
The Exokernel Architecture
Now, let's explore the Exokernel architecture and its core principles:

1. Resource Exposure
In an Exokernel, programs have direct access to hardware resources such the CPU, memory,
and I/O units. Applications may now handle these resources with greater precision because
they have fine-grained control over them.

2. Protection and Isolation


Exokernels provide robust isolation and protection features despite exposing resources.
Applications are protected from illegal access and intervention by running in separate address
spaces.

3. Minimalism
Exokernels take a straightforward stance. They leave high-level services and resource
management to application-level libraries and only offer the absolute necessities in
abstractions. This minimalism encourages adaptability and effectiveness.
4. Flexibility
Exokernels adopt a direct posture. They only provide the bare minimum in abstractions,
leaving high-level services and resource management to application-level libraries. This
minimalism promotes efficacy and adaptability.

Virtual Machines
 A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating
system kernel as though they were all hardware.
 A virtual machine provides an interface identical to the underlying bare hardware.
 The operating system creates the illusion of multiple processes, each executing on its own processor with
its own (virtual) memory.
 The resources of the physical computer are shared to create the virtual machines.

✦ CPU scheduling can create the appearance that users have their own processor.
✦ Spooling and a file system can provide virtual card readers and virtual line printers.
✦ A normal user time-sharing terminal serves as the virtual machine operator’s console.

 System Models

Non-virtual Machine Virtual Machine


 Advantages/Disadvantages of Virtual Machines
 The virtual-machine concept provides complete protection of system resources since each virtual
 machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of
resources.
 A virtual-machine system is a perfect vehicle for operating-systems research and development. System
development is done on the virtual machine, instead of on a physical machine and so does not disrupt
normal system operation.
 The virtual machine concept is difficult to implement due to the effort required to provide an exact

duplicate to the underlying machine.

INTRODUCTION TO PROCESSES:
A process is basically a program in execution. The execution of a process must progress in a sequential
fashion.
 A process will need certain resources—such as CPU time, memory, files, and I/O devices —to
accomplish its task.
 These resources are allocated to the process either when it is created or while it is executing.
 Definition:A process is defined as an entity which represents the basic unit of work to be
implemented in the system.
PROCESSES:

 A process is mainly a program in execution where the execution of a process must progress in a
sequential order or based on some priority or algorithms.
 In other words, it is an entity that represents the fundamental working that has been assigned to a
system.
 When a program gets loaded into the memory, it is said to as process. This processing can be
categorized into 4 sections. These are:
o Heap
o Stack
o Data
o Text

Informally, as mentioned earlier, a process is a program in execution.


A process is more than the program code, which is sometimes known as the text section. It also includes the
current activity, as represented by the value of the program counter and the contents of the processor's registers.

A process generally also includes the process stack, which contains temporary data (such as function
parameters, return addresses, and local variables), and a data section, which contains global variables.
A process may also include a heap, which is memory that is dynamically allocated during process run time.
STACK - The process Stack contains the temporary data such as method/function parameters, return
address and local variables.
 HEAP - This is dynamically allocated memory to a process during its run time.
 TEXT - This includes the current activity represented by the value of Program Counter and the
contents of the processor's registers.
 DATA - This section contains the global and static variables.

We emphasize that a program by itself is not a process; a program is a passive entity, such as a file
containing a list of instructions stored on disk (often called an executable file), whereas a process is an
active entity, with a program counter specifying the next instruction to execute and a set of associated
resources.
A program becomes a process when an executable file is loaded into memory.

Two common techniques for loading executable files are double-clicking an icon representing the executable file
and entering the name of the executable file on the command line
PROCESS STATE / PROCESS LIFE CYCLE:

When a process executes, it passes through different states.


 These stages may differ in different operating systems, and the names of these states are also not
standardized.

It is important to realize that only one process can be running on any processor at any instant. Many
processes may be ready and waiting,

Process Control Block


THREAD in OS
A thread is a single sequence stream within a process. Threads are
also called lightweight processes as they possess some of the
properties of processes. Each thread belongs to exactly one process.
 In an operating system that supports multithreading, a process
can consist of many threads.
 All threads belonging to the same process share code section,
data section, and OS resources (e.g. open files and signals), but
each thread has its own (thread control block) - thread ID,
program counter, register set, and a stack.
PROCESS SCHEDULING:
 A uniprocessor system can have only one running process. If more process exist, the rest must
wait until the CPU is free and can be rescheduled.
 The objective of mult iprogramming is to have some process running at all times, to maximize
CPU utilization.
 The objective of time sharing is to switch the CPU among processes so frequently that users can
interact with each program while it is running.
 To meet these objectives, the process scheduler selects an available process (possibly from a set
of several available processes) for program execution on the CPU.
Diagram Showing CPU Switch Process To Process

PROCESS SCHEDULING QUEUES:


 The OS maintains all PCBs in Process Scheduling Queues.

 The OS maintains a separate queue for each of the process states and PCBs of all processes in
the same execution state are placed in the same queue.
 When the state of a process is changed, its PCB is unlinked from its current queue and moved to
its new state queue.
 Process migration between the various queues:
o Job queue
o Ready queue
o Device queues

Process Scheduling Queue

JOB QUEUE−This queue keeps all the processes in the system.


 READY QUEUE − This queue keeps a set of all processes residing in main memory, ready and
waiting to execute. A new process is always put in this queue.
 DEVICE QUEUES −The processes which are blocked due to unavailability of an I/O device
constitute this queue.

The OS can use different policies to manage each queue (FIFO, Round Robin, Priority, etc.).
 The OS scheduler determines how to move processes between the ready and run queues which can
only have one entry per processor core on the system; in the above diagram, it has been merged with the
CPU.

TWO STATE PROCESS MODEL:


 Two-state process model refers to running and non-running states which are described below
 RUNNING
o When a new process is created, it enters into the system as in the running state.
 NOT RUNNING
o 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.

Queuing Diagram Representation For Process Scheduling

SCHEDULERS:
 Schedulers are special system software which handles the 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 –
o Long-Term Scheduler
o Short-Term Scheduler
o Medium-Term Scheduler
LONG TERM SCHEDULER:
o It is also called a job scheduler.
o A long-term scheduler determines which programs are admitted to the system for processing.
o It selects processes from the queue and loads them into memory for execution.
o Process loads into the memory for CPU scheduling.
o The primary objective of the job scheduler is to provide a balanced mix of jobs, such as I/O
bound and processor bound.

o 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.

SHORT TERM SCHEDULER:


o It is also called as CPU scheduler.
o Its main objective is to increase system performance in accordance with the chosen set of criteria. It
is the change of ready state to running state of the process.
o CPU scheduler selects a process among the processes that are ready to execute and allocates CPU to
one of them.
o Short-term schedulers, also known as dispatchers, make the decision of which process to execute
next.
o Short-term schedulers are faster than long-term schedulers.

 MEDIUM TERM SCHEDULER:


o Medium-term scheduling is a part of swapping.
o It removes the processes from the memory.
o It reduces the degree of multiprogramming. The medium-term scheduler is in-charge of handling
the swapped out-processes.
o A running process may become suspended if it makes an I/O request.
o A suspended process cannot make any progress towards completion.
o In this condition, to remove the process from memory and make space for other processes, 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.

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.
Switching the CPU to another process requires performing a state save of the current process and a state restore of
a different process. This task is known as Context Switching.
When a context switch occurs, the kernel saves the context of the old process in its PCB and loads the saved
context of the new process scheduled to run.
 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.
 Context switches are computationally intensive since register and memory state must be saved and
restored.
 To avoid the amount of context switching time, some hardware systems employ two or more
sets of processor registers.

When the process is switched, the following information is stored for later use.
o Program Counter
o Scheduling information
o Base and limit register value
o Currently used register
o Changed State
o I/O State information
o Accounting information

PROCESS CREATION:
 Parent process creates children processes, which, in turn create other processes, forming a tree of
processes.

Process Creation Diagram


 Resource sharing
o Parent and children share all resources.
o Children share subset of parent’s resources.

Each of these new processes may in turn create other processes, forming a tree of processes.
 When a process creates a subprocess, that subprocess may be able to obtain its resources directly
from the operating system, or it may be constrained to a subset of the resources of the parent process.
 When a process creates a new process, two possibilities exist in terms of execution:
o The parent continues to execute concurrently with its children.
o The parent waits until some or all of its children have terminated.

CPU SCHEDULING
 CPU scheduling is a process which allows one process to use the CPU while the execution of another
process is on hold(in waiting state) due to unavailability of any resource like I/O etc, thereby making
full use of CPU
 Whenever the CPU becomes idle, the operating system must select one of the processes in the ready
queue to be executed.
 The selection process is carried out by the short-term scheduler (or CPU scheduler).

CPU SCHEDULING: DISPATCHER


 Another component involved in the CPU scheduling function is the Dispatcher. The dispatcher is
the module that gives control of the CPU to the process selected by the short-term scheduler. This
function involves:
 Switching context
 Switching to user mode
 Jumping to the proper location in the user program to restart that program from where it left last time.
 The dispatcher should be as fast as possible, since it is invoked during every process switch.
o The time it takes for the dispatcher to stop one process and start another running is known as the
DISPATCH LATENCY.

TYPES OF CPU SCHEDULING:


 CPU scheduling decisions may take place under the following four circumstances:
 When a process switches from the running state to the waiting state(for I/O request or invocation of
wait for the termination of one of the child processes).
 When a process switches from the running state to the ready state (for example, when an interrupt
occurs).
 When a process switches from the waiting state to the ready state(for example, completion of I/O).
 When a process terminates.

CPU SCHEDULING: SCHEDULING CRITERIA


 Different CPU scheduling algorithms have different properties, and the choice of a particular
algorithm may favor one class of processes over another.
 In choosing which algorithm to use in a particular situation, we must consider the properties of the
various algorithms.
 Many criteria have been suggested for comparing CPU scheduling algorithms.
 Which characteristics are used for comparison can make a substantial difference in which algorithm
is judged to be best.
 The criteria include the following
 CPU UTILIZATION:
o We want to keep the CPU as busy as possible.

o Conceptually, CPU utilization can range from 0 to 100 percent.

o In a real system, it should range from 40 percent (for a lightly loaded system) to 90 percent (for a
heavily used system).
 THROUGHPUT
o It is the total number of processes completed per unit time or rather say total amount of work done in
a unit of time. This may range from 10/second to 1/hour depending on the specific processes.

 TURNAROUND TIME
o It is the amount of time taken to execute a particular process, i.e. The interval from time of
submission of the process to the time of completion of the process(Wall clock time).
WAITING TIME
o The sum of the periods spent waiting in the ready queue amount of time a process has been waiting
in the ready queue to acquire get control on the CPU.
 LOAD AVERAGE
o It is the average number of processes residing in the ready queue waiting for their turn to get into the
CPU.
 RESPONSE TIME
o Amount of time it takes from when a request was submitted until the first response is produced.
Remember, it is the time till the first response and not the completion of process execution (final
response).

SCHEDULING ALGORITHMS:

Two types of Scheduling algorithms

Non-preemptive scheduling allows a process to hold the CPU until it terminates or enters a waiting
state, preventing interruption by higher-priority tasks. In contrast, preemptive scheduling allows the
operating system to interrupt a currently running process to allocate the CPU to a higher-priority or
more urgent task. Non-preemptive is simpler with lower overhead, while preemptive offers better
responsiveness and is used in modern operating systems.
-*

You might also like