• No results found

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

N/A
N/A
Protected

Academic year: 2021

Share "Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling"

Copied!
16
0
0

Loading.... (view fulltext now)

Full text

(1)

Scheduling 0 : Levels

High level scheduling:

Deciding whether another process can run is process table full?

user process limit reached? load to swap space or memory?

Medium level scheduling:

Balancing the system load swap out a process?

swap in a process?

Low level scheduling

(2)

Scheduling 1 : Objectives

System throughput should be maximised. Graceful degradation of performance. No sudden collapse!

Provide a tolerable response time.

(3)

Scheduling 2 : Criteria

Job Priority : Depends on

Category of job: batch,

on-line, real-time.

CPU bound or I/O bound. Resource requirements Waiting time to date. Resources used to date.

(4)

Scheduling 3 : Low-level

Low-level scheduling can be:

Preemptive

Current process may be interrupted by o/s. new process arrived

interrupt placed blocked process in Ready queue

clock interrupt (time up). Non-Preemptive

Process executes until it terminates

blocks on I/O or system call. Cooperative

(5)

Scheduling 4 : Low-level Policies i

First-come-first-served, or FIFO.

Non-preemptive.

first process to arrive in queue gets CPU

when this process stops running, next in queue gets CPU ie. the process that has been waiting longest goes next. favours cpu-bound processes.

Round Robin

Uses a time-slice and preemption. each process runs for a short period

when timer expires, or process blocks, next process runs design issue is length of time-slice.

(6)

Scheduling 5 : Low-level Policies ii

Shortest job first.

non-preemptive

process with shortest expected processing time goes first. need to calculate processing time for each job.

risk of starvation for long jobs

Shortest remaining time

preemptive version of SJF

process with shortest remaining processing time runs. preempted if new shorter job arrives in queue.

risk of starvation again.

(7)

Scheduling 6 : Low-level iii.

Highest Response Ratio Next

non-preemptive.

process with the highest ratio of ’waiting time : run time’ goes next. Favours shorter jobs.

Doesn’t starve longer jobs

Still need to know how long the job will take to complete.

Priority = waiting time + runtime runtime

(8)

Scheduling 7 : Low-level iv.i

Multi-level feedback queues

preemptive Run Queue 0 CPU Run Queue 1 CPU Run Queue 1 CPU Run Queue 0 Run Queue 1 Run Queue 2 CPU Run Queue 0 Run Queue 1 Run Queue 2 CPU

(9)

Scheduling 8 : Low-level iv.ii

Long processes can get starved, therefore :

time quantum = τ

Process first placed on RQ0

gets time slice of length τ x 20

gets time slice of length τ x 21

gets time slice of length τ x 22

gets time slice of length τ x 2i

If process does not complete then move to RQ1

If process does not complete then move to RQ2

(10)

Scheduling 9 : Generic Unix

Traditional time-sharing, multi-user, interactive system. Uses multi-level feedback with round-robin queues. Preemption after 1 sec.

Priority is recalculated every second using

CPUj(i) = CPUj(i − 1) 2

Pj(i) = Basej + CPUj(i)

2 + nicej

from Operating Systems, W. Stallings 5th Ed. Pearson.

Where CPUj(i) Pj(i) Basej nicej utilization by j in time i priority of j at start of i

base priority of process j

user adjustment for j

(11)

Scheduling 9.1 : generic Unix

Queues are, in order of priority

Swapper

Block I/O device control

File Manipulation

Character I/O Device control

User Process

(12)

Scheduling 10 : Linux pre 2.6

Linux has one run queue, but uses several scheduling policies, a number of

priority levels and a ’niceness’ factor to control scheduling:

Niceness is in the range -20 to +19, (user processes only)

The priority is recorded in the priority field of the task_struct

and is in the range 0 - 99

The policy is recorded in the policy field of the task_struct

Policies are

SCHED_RR SCHED_FIFO SCHED_OTHER

(13)

Scheduling 10.1 : Linux pre 2.6

SCHED_RR

process base priority fixed for life in the range 1 .. 99 Round-Robin scheduling

runs until

it blocks itself -> moved to wait Q

preempted by higher priority process -> run Q uses up its quantum -> moved to run Q

SCHED_FIFO

process base priority fixed for life in the range 1 .. 99 First come first served scheduling

runs until

it blocks itself -> moved to wait Q

preempted by higher priority process -> run Q it completes current task -> moved to run Q

(14)

Scheduling 10.2 : Linux pre 2.6

SCHED_OTHER

Used for all normal processes. Process base priority fixed at 0

Process has ’niceness’ factor which affects quantum.

The counter field in task_struct is the quantum for a process.

Decremented every clock tick when process running. Scheduler called when value = 0.

counter field value recalculated as follows

counter = Scale_Factor × (20 − (nice) + 1)

The Scale_Factor is based on the processor speed and is to ensure that the standard quantum is around 50ms.

(15)

Scheduling 10.3 : Linux pre 2.6

Remember, all runnable processes are held in the same queue!

The scheduler decides which process to run next by calculating the

goodness

factor.

For policies

SCHED_RR SCHED_FIFO

goodness = 1000 + priority

(16)

Scheduling 10.4 : Linux pre 2.6

SCHED_OTHER

is a bit more complex

goodness = p->counter; if (p->processor == this_cpu) goodness += PROC_CHANGE_PENALTY; if (p->mm == this_mm || !p->mm) goodness += 1; goodness += 20 - p->nice; goto out;

If the counter value is zero for all processes then it is recalculated as

References

Related documents

Subject to the terms and conditions of the policy, we will reimburse the Vet Expenses incurred by you as a result of a Treatment to the insured Pet for covered Accidental Injury

Power LED: turn on when servo drive is power on. Charge LED: turn on when servo drive is power on. After power off, it will be on until there is no charge in the capacitance of

The TCAM-based deep packet inspection algorithm developed in this paper uses a jumping window scheme, which is supported by position-aware sub-patterns and the state transition

Our contributions are a model of a lost sales retail inventory system with record inaccuracies, the derivation of a Bayesian inventory record in such a system, and policies based

IAI is in the right path for being ready to AEC while IAI needs to keep up raising the number of accountants and improving on quality assurance, socialize on international

Development of robotic instruments for bone removal will definitely improve the application of the surgical robot in fields like spine surgery and anterior skull base surgery,

Using Chi-squared analyses, respondents’ an- swers to how frequently they treated each of the cat- egories of special needs patients were compared with their responses to 1) year

Please also bring a Turnitin print-off of your essay to your seminar leader in class on the submission date with your signed essay entry form.. Extensions need the permission of