Top Banner
33

Scheduling Linux Scheduling Linux Scheduling Policy Classification Of Processes In Linux Linux Scheduling Classes Process States In Linux.

Dec 26, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.
Page 2: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

SchedulingLinux SchedulingLinux Scheduling PolicyClassification Of Processes In LinuxLinux Scheduling ClassesProcess States In LinuxAdvantagesLimitations

Page 3: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

The set of rules used to determine when and how to select a new process to run is called scheduling.

The job of allocating processor time to different tasks within an operating system.

Page 4: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Like any time-sharing system, Linux achieves the magical effect of an apparent simultaneous execution of multiple processes by switching from one process to another in a very short time frame. 

Page 5: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Linux scheduling has several objectives:

Fast process response time..

Better throughput..

Better processor utilization..

Minimize the idle time etc..

Page 6: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

The response from a program should be as fast as possible.

The scheduler should maximize throughput

Better processor utilization.

The idle time of the processor should be minimized.

Page 7: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Based on time-sharing Time slice

Based on priority ranking Static Dynamic

Classification of processes Interactive processes Batch processes Real-time processes

Page 8: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Linux scheduling is based on the time sharing technique:

Each process is assigned a small quantum or time slice that it is allowed to execute.

Page 9: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

A single processor can run only one process at any given time.

If a currently running process is not terminated when its time slice or quantum expires, the process switches to another.

Page 10: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Linux scheduling policy is also based on ranking processes according to their priority:

Static Priority

Dynamic Priority

Page 11: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

The maximum size of the time slice a process should be allowed before being forced to allow other processes to compete for the processor.

Page 12: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Priorities are adjusted over time to eliminate starvation.

Processes that have not received the Processor for a long time get their priorities increased.

Processes that have received the Processor often get their priorities decreased.

Page 13: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Complicated algorithms are sometimes used to derive the current priority of a process, but the end result is the same: each process is associated with a value that denotes how appropriate it is to be assigned to the processor.

Page 14: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

The scheduler keeps track of what processes are doing and adjusts their priorities periodically; in this way, processes that have been denied the use of the CPU for a long time interval are boosted by dynamically increasing their priority.

Correspondingly, processes running for a long time are penalized by decreasing their priority.

Page 15: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Interactive processes..

Batch processes..

Real-time processes..

Page 16: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Interact constantly with their users, and therefore spend a lot of time waiting for key presses and mouse operations.

When input is received, the process must be woken up quickly.

Typical interactive programs are text editors, and graphical applications.

Page 17: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Do not need user interaction.

Often run in the background because such processes do not need to be very responsive, they are often penalized by the scheduler.

Typical batch programs are programming language compilers, database search engines, and scientific computations.

Page 18: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

These processes should never be blocked by lower-priority processes.

Typical real-time programs are video and sound applications, robot controllers, and programs that collect data from physical sensors.

Page 19: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Linux process is scheduled according to the following scheduling classes:

SCHED_FIFO..

SCHE_RR..

SCHED_OTHER..

Page 20: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

A First-In, First-Out real-time process. When the scheduler assigns the CPU to the process, it leaves the process descriptor in its current position in the run queue list. If no other higher-priority real-time process is runnable, the process continues to use the CPU as long as it wishes, even if other real-time processes that have the same priority are runnable.

FIFO processes continue to run until they either exit or block.

Page 21: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Round Robin real-time process. When the scheduler assigns the CPU to the process, it puts the process descriptor at the end of the run queue list. This policy ensures a fair assignment of CPU time to all SCHED_RR real-time processes that have the same priority.

Page 22: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Linux kernel is non-preemptive. But processes are preemptive.

Processes are pre-emptible in user mode but not in kernel mode.

Page 23: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Linux uses process preemption, a process is preempted when:

The dynamic priority of the currently running process is lower than the process waiting in the run queue.

A process may also be preempted when its time quantum expires.

Page 24: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

The time quantum is the numeric value that represents how long a task can run until it is preempted. 

Page 25: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

The time quantum should Neither too long nor too short.

The scheduler policy must dictate a default time Quantum.

Page 26: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Too short:

If the time quantum is too short, then:

short processes will move through the system relatively quickly.

There is Processing overhead involved in handling clock interrupt and performing the scheduling and dispatching function.

Page 27: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Too long:

If time quantum is too long then:

Processes no longer appear to be executed concurrently.

Degrades the response time of interactive applications.

Degrades the responsiveness of the system.

Page 28: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Linux processes have the following states:

Running..

Waiting..

Stopped..

Zombie..

Page 29: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Running:  Process is either running or ready to run

Waiting : The process is waiting for an event or for a

resource.

Page 30: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Stopped:  Process is stopped or halted and can be restarted

by some other process

Zombie:  In this state, the process will be terminated and

the information will still be available in the process table.

Page 31: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Suitable for standard workstation use, where few processes is in the running or ready state at a time, as this proves very good response times.

The scheduling algorithm of Linux is both self-contained and relatively easy to follow.

Page 32: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Does not scale very well as the number of process grows because it has to recomputed dynamic priorities.

Page 33: Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.

Thanks For Your Attention..