Schedulers:
Scheduling refers to the methods by which threads, processes
or data flows are given access to system resources. The need for scheduling
arises usually due to multitasking or multiplexing. The former refers to
execution of more than one processes while the latter refers to transmitting
multiple data streams across a single physical channel. The goal of the scheduler can be one of the
following:
1)
To increase throughput - such as to the total number of processes
that complete execution in unit time
2)
To decrease latency – such that the total time
between the submission of a process and its completion (turnaround time) is
reduced or the time it takes between submitting a job and its first response
(response time) is reduced
3)
To increase fairness – where the cpu time
allotted to each process is fair or weighted based on priority ( the process
priority and workload is utilized)
4)
To decrease waiting time – time the process
remains in the waiting queue.
As we can see the goals can be conflicting, such as
throughput vs latency. Thus schedulers can be instantiated for different
goals. Preference given to the goals
depends upon requirements.
Schedulers may have additional requirements such as to
ensure that scheduled processes can meet deadlines so that the system is
stable. This is true for embedded systems or real-time environments.
The notion of a scheduler brings up a data structure of one
or more queues. In fact, the simplest scheduler is a queue. A ready queue is
one where jobs can be retrieved for execution. Queues can also be prioritized.
Schedulers may perform their actions one time, every once in
a while or at regular intervals. They are classified accordingly as long-term,
mid term or short term schedulers. The
long-term or admission schedulers are generally used in batch processing
systems where the scheduler admits the processes or delays and determines the
degree of concurrency. Usually processes are distinguished as CPU-bound or I/O
bound. The mid term scheduler usually swaps in or swaps out the jobs in order
to free up the processes can execute and the system resources are available for
them to execute. The short term
scheduler decides which of the jobs needs to be executed at periodic regular
intervals called quantums.
Scheduling Algorithm can be one of the following:
FIFO – First Come First Served is a simple queue.
Shortest remaining time – also known as Shortest Job First,
the scheduler tries to arrange the jobs in the order of the least estimated
processing time remaining.
Fixed priority pre-emptive scheduling – A rank is assigned
to each job and the scheduler arranges the job in the ready queue based on this
rank. Lower priority processes can get interrupted by incoming higher priority
processes.
Round-Robin scheduling – The scheduler assigns a fixed time
unit per process and cycles through them. This way starvation is avoided.
Multilevel queue scheduling – is used when processes can be
divided into groups.
#codingexercise
Double GetAlternateNumberRangeMean()(Double [] A)
{
if (A == null) return 0;
Return A.AlternateNumberRangeMean();
}
#codingexercise
Double GetAlternateNumberRangeMean()(Double [] A)
{
if (A == null) return 0;
Return A.AlternateNumberRangeMean();
}