CPU scheduling:
Basic concepts:
In a simple computer system running a single process, the time spent waiting for I/O is wasted, and those CPU cycles are lost forever.In multiprogramming system running more than one process, the time is not wasted, and CPU is allocated to another process.
Scheduling is fundamental operating system function.
All computer resources are scheduled before use. CPU is one of the primary computer resources
A scheduling system allows one process to use the CPU while another is waiting for I/O, thereby making full use of CPU.
CPU scheduler:
Whenever the CPU becomes idle, it is the job of the CPU Scheduler to select another process from the ready queue to run next.The storage structure for the ready queue can be implemented as FIFO queue,priority queue,a tree
or an unordered linked list.
Preemptive Scheduling:
CPU scheduling decisions take place under one
of four conditions:
-
When a process switches from the running state to the waiting state
-
When a process switches from the running state to the ready state
-
When a process switches from the waiting state to the ready state
-
When a process terminates.
-
For conditions 1 and 4 there is no choice - A new process must be selected.
-
For conditions 2 and 3 there is a choice - To either
continue running the current process, or select a different one.
Preemptive Scheduling-Once the CPU has been allocated to a process,the CPU is released from the process before it finishes it work.
This Scheduling
scheme is called as Preemptive Scheduling.
Non-Preemptive Scheduling-Once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state
This Scheduling
scheme is called as Non-Preemptive Scheduling.
This Scheme is
used by Microsoft Windows 3.1
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 newly loaded program.
-
-
The dispatcher needs to be as fast as possible, as it is
invoked on every process switch. The time consumed by the
dispatcher is known as dispatch latency.
Scheduling Criteria:
There are several different criteria to
consider when trying to select the "best" scheduling
algorithm for a particular situation and environment, including:
-
CPU utilization - CPU utilization range from 0 to 100% . In a real system CPU usage should range from 40% (for lightly loaded system) to 90% ( for a heavily loaded system )
-
Throughput - Number of processes completed per unit time. May range from 10 / second to 1 / hour depending on the processes.
-
Turnaround time - Time required for a particular process to complete, from submission time to completion.
-
Waiting time - How much time processes spend in the ready queue waiting their turn to get on the CPU.
-
Response time - The time taken in an
interactive program from the issuance of a command to the commence
of a response to that command.
No comments:
Post a Comment