Operating System Chapter 4 - Ma
Operating System Chapter 4 - Ma
A COLLEGE
ASSOSA CAMPUS
• Introduction
• If the new process arrived at the ready queue has a higher priority than
the currently running process, the CPU is preempted, which means the
processing of the current process is stopped and the incoming new
process with higher priority gets the CPU for its execution.
• At that time, the lower priority task holds for some time and resumes
when the higher priority task finishes its execution.
What is Non- Preemptive Scheduling?
• The process that keeps the CPU busy will release the CPU either by
switching context or terminating.
• It is the only method that can be used for various hardware platforms.
• All the running processes will make use wait for a longer time if some high priority
method up
• Maximum throughput
• Each process has its own memory • Threads use the memory of the
space process they belong to.
• Inter-process communication is • Inter-thread communication can be
slow as processes have different faster than inter-process
memory addresses communication.
• Context switching between • Context switching between threads
processes is more expensive. of the same process is less
• Processes don’t share memory expensive
with other processes. • Threads share memory with other
threads of the same process.
SCHEDULING
• The part of the operating system that makes the choice is called the
scheduler, and the algorithm it uses is called the scheduling algorithm.
• Many of the same issues that apply to process scheduling also apply to
thread scheduling, although some are different. When the kernel
manages threads, scheduling is usually done per thread, with little or no
regard to which process the thread belongs.
Continued
• The objective of multiprogramming 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. In uniprocessor only one process is running.
• A process migrates between various scheduling queues throughout its
lifetime.
• The process of selecting processes from among these queues is carried
out by a scheduler.
• The aim of processor scheduling is to assign processes to be executed by
the processor.
• Scheduling affects the performance of the system, because it determines
which process will wait and which will progress.
Types of Scheduling
• Long-term Scheduling: Long term scheduling is performed when a
new process is created.
• If the number of ready processes in the ready queue becomes very
high, then there is an overhead on the operating system (i.e.,
processor) for maintaining long lists, context switching and
dispatching increases.
• Medium-term Scheduling: Medium-term scheduling is a part of the
swapping function. When part of the main memory gets freed, the
operating system looks at the list of suspend ready processes, decides
which one is to be swapped in (depending on priority, memory and
other resources required, etc.).
• Short-term Scheduling: Short-term scheduler is also called as
dispatcher. Short-term scheduler is invoked whenever an event occurs,
that may lead to the interruption of the current running process.
Scheduling Algorithm
• A scheduling algorithm is the algorithm which dictates how much
CPU time is allocated to Processes and Threads.
• The goal of any scheduling algorithm is to fulfill a number of criteria:
no task must be starved of resources – all tasks must get their chance
at CPU time.
• Scheduling algorithms or scheduling policies are mainly used for
short-term scheduling.
• The main objective of short-term scheduling is to
allocate processor time in such a way as to optimize one or more
aspects of system behavior.
• For these scheduling algorithms assume only a single processor is
present.
Continued
• Scheduling algorithms decide which of the processes in the ready
queue is to be allocated to the CPU is basis on the type of scheduling
policy and whether that policy is either preemptive or non-preemptive.
• For scheduling arrival time and service time are also will play a role.
• If time quantum is less for scheduling then its Gantt chart seems to be
too big.
Some Points to Remember
1.Decreasing value of Time quantum:-With the decreasing value of
time quantum
• The number of context switches increases.
• The Response Time decreases
• Chances of starvation decrease in this case.
For the smaller value of time quantum, it becomes better in terms
of response time.
2.Increasing value of Time quantum:-With the increasing value of
time quantum
For the higher value of time
•The number of context switch decreases quantum, it becomes better in
•The Response Time increases terms of the number of the
•Chances of starvation increases in this case. context switches.
Continued
3. If the value of time quantum is increasing then Round Robin
Scheduling tends to become FCFS Scheduling.
4.In this case, when the value of time quantum tends to infinity then
the Round Robin Scheduling becomes FCFS Scheduling.