Information Technology Reference
In-Depth Information
Task is
preempted by
scheduler
Task is
scheduled to run
on CPU
Ready
Running
I/O or other task is
complete
Task is waiting for I/O
or another task to
complete
Suspended
FIGURE 3.1
State diagram showing possible task states along with their transitions.
it “is best described as a task that exists but is unavailable to the operating system”
(Laplante, 2005). Figure 3.1 shows a state diagram with possible task states along
with their transitions.
A context switch occurs when a task that has not completed is preempted by
another task. This can happen because the task running has a lower priority or its
scheduled execution time has expired. It also can refer to when the flow of control
is passed from the application to the kernel. The “context” of the task must be
switched from the current task's information to the new task's information. Task-
specific information commonly includes register information and the current program
counter. The task information that is saved is determined by the operating system. It
takes time to save off the data from the current task and to load the data associated
with the new task. This latency is considerable, and it is the responsibility of the
operating system to minimize this time as much as possible to maintain the efficiency
of the system. A context switch occurs whenever the flow of control moves from
one task to another or from task to kernel. Assuming we are dealing with a single
processor system, there can only be one task that has control of the processor at
a time.
With a multitasking environment, each task has a scheduled time slice where it
is allowed to run on the processor. If the task has not completed when its time has
expired, the timer causes an interrupt to occur and prompts the scheduler to switch
in the next task. Tasks may be scheduled in a round-robin fashion, where each of the
tasks has equal priority and a determined amount of time to run. Another method is
where tasks are assigned various priorities and the tasks with the highest priorities
are given preference to run over lower priority tasks.
Search WWH ::




Custom Search