Scheduling Linux Scheduling Linux Scheduling Policy Classification Of Processes In Linux Linux...

33

Transcript of Scheduling Linux Scheduling Linux Scheduling Policy Classification Of Processes In Linux Linux...

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

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.

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. 

Linux scheduling has several objectives:

Fast process response time..

Better throughput..

Better processor utilization..

Minimize the idle time etc..

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.

Based on time-sharing Time slice

Based on priority ranking Static Dynamic

Classification of processes Interactive processes Batch processes Real-time processes

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.

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.

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

Static Priority

Dynamic Priority

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

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.

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.

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.

Interactive processes..

Batch processes..

Real-time processes..

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.

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.

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.

Linux process is scheduled according to the following scheduling classes:

SCHED_FIFO..

SCHE_RR..

SCHED_OTHER..

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.

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.

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

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

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.

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

The time quantum should Neither too long nor too short.

The scheduler policy must dictate a default time Quantum.

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.

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.

Linux processes have the following states:

Running..

Waiting..

Stopped..

Zombie..

Running:  Process is either running or ready to run

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

resource.

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.

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.

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

Thanks For Your Attention..