CPU SCHEDULING
CONTENT
• CPU SCHEDULING
• SHORTEST JOB FIRST(SJF)
• ROUND ROBIN
• PRIORITY SCHEDULING
• VIRTUAL MACHINE
WHAT IS 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. The aim of CPU scheduling is to make the system efficient,
fast and fair.
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.
TYPES OF CPU SCHEDULING
• 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
• CPU Utilization
To make out the best use of CPU and not to waste any CPU cycle, CPU would be working
most of the time(Ideally 100% of the time). Considering a real system, CPU usage should
range from 40% (lightly loaded) to 90% (heavily loaded.)
• Throughput
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
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).
CONTINUE:
• Waiting Time
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
It is the average number of processes residing in the ready queue waiting for their turn to
get into the CPU.
• Response Time
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).
SHORTEST JOB FIRST
CONT…
• process with less burst time will always execute first.
• this process is both Premetive and non-Premetive scheduling.
• as it is non-primitive scheduling algorithm so processes priority does not matter.
• as it is Premetive scheduling algorithm preferd to minimize waiting time better
than FCFS scheduling.
• easy to implement in batch system because in batch system system CPU time is
already known.
NON-PREMEPTIVE:
PRE-EMPETIVE:
Round robin
• round Robin is a CPU scheduling algorithm where each process is assigned a fixed
time slot in a cyclic way.
It is simple, easy to implement, and starvation-free as all processes get fair share of
CPU.
One of the most commonly used technique in CPU scheduling as a core.
It is preemptive as processes are assigned CPU only for a fixed slice of time at most.
The disadvantage of it is more overhead of context switching.
Continue…
EXAMPLE-1:
Time Quantum : 5ms
EXAMPLE-2:
Process Arrival Time Service Time
1 0 8
2 1 4
3 2 9
4 3 5
Time Quantum= 4unit.
Ghantt chart:
AVERAGE WAITING TIME:
=((20-8)+(7-4)+(24-9)+(22-5))
=11.75
AVERAGE TURN AROUND TIME:
=((20-0)+(8-1)+(24-2)+(22-3))
=18.25
PRIORITY SCHEDULING
PRIORITY SCHEDULING
• Priority scheduling is a non-preemptive algorithm and one of the most common
scheduling algorithms in batch systems
• Each process is assigned a priority.
• Process with the highest priority is to be executed first and so on.
• Processes with same priority are executed on first come first served basis.
NUMERIC
VIRTUAL MACHINE
VIRTUAL MACHINE
• In computing, a virtual machine (VM) is an emulation of a computer system.
Virtual machines are based on computer architectures and provide functionality
of a physical computer. Their implementations may involve specialized
hardware, software, or a combination.
• A "virtual machine" was originally defined by Popek and Goldberg as "an
efficient, isolated duplicate of a real computer machine. Current use includes
virtual machines that have no direct correspondence to any real hardware.
• The physical, "real-world" hardware running the VM is generally referred to as
the 'host', and the virtual machine emulated on that machine is generally
referred to as the 'guest'. A host can emulate several guests, each of which can
emulate different operating systems and hardware platforms.
VIRTUAL MACHINE
CONTINUE…..
• There are different kinds of virtual machines, each with different functions:
• System virtual machines :
(also termed full virtualization VMs) provide a substitute for a real machine. They provide
functionality needed to execute entire operating systems. A hypervisor uses native execution to
share and manage hardware, allowing for multiple environments which are isolated from one
another, yet exist on the same physical machine. Modern hypervisors use hardware-assisted
virtualization, virtualization-specific hardware, primarily from the host CPUs.
CONTINUE..
• he desire to run multiple operating systems was the initial motive for virtual machines, so as to
allow time-sharing among several single-tasking operating systems. In some respects, a system
virtual machine can be considered a generalization of the concept of virtual memory that
historically preceded it.
• IBM's CP/CMS, the first systems to allow full virtualization, implemented time sharing by
providing each user with a single-user operating system, the Conversational Monitor
System(CMS). Unlike virtual memory, a system virtual machine entitled the user to write
privileged instructions in their code. This approach had certain advantages, such as adding
input/output devices not allowed by the standard system.
CONTINUE…
• Process virtual machines:
are designed to execute computer programs in a platform-independent environment.
Some virtual machines, such as QEMU, are designed to also emulate different architectures and
allow execution of software applications and operating systems written for another CPU or
architecture. Operating-system-level virtualization allows the resources of a computer to be
partitioned via the kernel's support for multiple isolated user space instances, which are usually
called containers and may look and feel like real machines to the end users.
CONTINUE…
• A process VM, sometimes called an application virtual machine, or Managed Runtime
Environment (MRE), runs as a normal application inside a host OS and supports a single process.
It is created when that process is started and destroyed when it exits. Its purpose is to provide
a platform-independent programming environment that abstracts away details of the underlying
hardware or operating system and allows a program to execute in the same way on any platform.
• A process VM provides a high-level abstraction – that of a high-level programming
language (compared to the low-level ISA abstraction of the system VM). Process VMs are
implemented using an interpreter; performance comparable to compiled programming languages
can be achieved by the use of just-in-time compilation.
THANK YOU

Operating System

  • 1.
  • 2.
    CONTENT • CPU SCHEDULING •SHORTEST JOB FIRST(SJF) • ROUND ROBIN • PRIORITY SCHEDULING • VIRTUAL MACHINE
  • 3.
    WHAT IS CPUSCHEDULING? • 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. The aim of CPU scheduling is to make the system efficient, fast and fair.
  • 4.
    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.
  • 5.
    TYPES OF CPUSCHEDULING • 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.
  • 6.
    CPU SCHEDULING: SCHEDULINGCRITERIA • CPU Utilization To make out the best use of CPU and not to waste any CPU cycle, CPU would be working most of the time(Ideally 100% of the time). Considering a real system, CPU usage should range from 40% (lightly loaded) to 90% (heavily loaded.) • Throughput 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 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).
  • 7.
    CONTINUE: • Waiting Time Thesum 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 It is the average number of processes residing in the ready queue waiting for their turn to get into the CPU. • Response Time 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).
  • 8.
  • 9.
    CONT… • process withless burst time will always execute first. • this process is both Premetive and non-Premetive scheduling. • as it is non-primitive scheduling algorithm so processes priority does not matter. • as it is Premetive scheduling algorithm preferd to minimize waiting time better than FCFS scheduling. • easy to implement in batch system because in batch system system CPU time is already known.
  • 10.
  • 12.
  • 14.
  • 15.
    • round Robinis a CPU scheduling algorithm where each process is assigned a fixed time slot in a cyclic way. It is simple, easy to implement, and starvation-free as all processes get fair share of CPU. One of the most commonly used technique in CPU scheduling as a core. It is preemptive as processes are assigned CPU only for a fixed slice of time at most. The disadvantage of it is more overhead of context switching. Continue…
  • 16.
  • 17.
    EXAMPLE-2: Process Arrival TimeService Time 1 0 8 2 1 4 3 2 9 4 3 5 Time Quantum= 4unit. Ghantt chart:
  • 18.
    AVERAGE WAITING TIME: =((20-8)+(7-4)+(24-9)+(22-5)) =11.75 AVERAGETURN AROUND TIME: =((20-0)+(8-1)+(24-2)+(22-3)) =18.25
  • 19.
  • 20.
    PRIORITY SCHEDULING • Priorityscheduling is a non-preemptive algorithm and one of the most common scheduling algorithms in batch systems • Each process is assigned a priority. • Process with the highest priority is to be executed first and so on. • Processes with same priority are executed on first come first served basis.
  • 21.
  • 22.
  • 23.
    VIRTUAL MACHINE • Incomputing, a virtual machine (VM) is an emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardware, software, or a combination. • A "virtual machine" was originally defined by Popek and Goldberg as "an efficient, isolated duplicate of a real computer machine. Current use includes virtual machines that have no direct correspondence to any real hardware. • The physical, "real-world" hardware running the VM is generally referred to as the 'host', and the virtual machine emulated on that machine is generally referred to as the 'guest'. A host can emulate several guests, each of which can emulate different operating systems and hardware platforms.
  • 24.
  • 25.
    CONTINUE….. • There aredifferent kinds of virtual machines, each with different functions: • System virtual machines : (also termed full virtualization VMs) provide a substitute for a real machine. They provide functionality needed to execute entire operating systems. A hypervisor uses native execution to share and manage hardware, allowing for multiple environments which are isolated from one another, yet exist on the same physical machine. Modern hypervisors use hardware-assisted virtualization, virtualization-specific hardware, primarily from the host CPUs.
  • 26.
    CONTINUE.. • he desireto run multiple operating systems was the initial motive for virtual machines, so as to allow time-sharing among several single-tasking operating systems. In some respects, a system virtual machine can be considered a generalization of the concept of virtual memory that historically preceded it. • IBM's CP/CMS, the first systems to allow full virtualization, implemented time sharing by providing each user with a single-user operating system, the Conversational Monitor System(CMS). Unlike virtual memory, a system virtual machine entitled the user to write privileged instructions in their code. This approach had certain advantages, such as adding input/output devices not allowed by the standard system.
  • 27.
    CONTINUE… • Process virtualmachines: are designed to execute computer programs in a platform-independent environment. Some virtual machines, such as QEMU, are designed to also emulate different architectures and allow execution of software applications and operating systems written for another CPU or architecture. Operating-system-level virtualization allows the resources of a computer to be partitioned via the kernel's support for multiple isolated user space instances, which are usually called containers and may look and feel like real machines to the end users.
  • 28.
    CONTINUE… • A processVM, sometimes called an application virtual machine, or Managed Runtime Environment (MRE), runs as a normal application inside a host OS and supports a single process. It is created when that process is started and destroyed when it exits. Its purpose is to provide a platform-independent programming environment that abstracts away details of the underlying hardware or operating system and allows a program to execute in the same way on any platform. • A process VM provides a high-level abstraction – that of a high-level programming language (compared to the low-level ISA abstraction of the system VM). Process VMs are implemented using an interpreter; performance comparable to compiled programming languages can be achieved by the use of just-in-time compilation.
  • 29.