Figure 3-4 shows internally processing for tasks (or worker processes) queued for an Adaptive Server engine in a single-CPU environment. Adaptive Server, not the operating system, dynamically schedules client tasks from the run queue onto the engine. When the engine finishes processing one task, it executes the task at the beginning of the run queue.
When a task begins running, the engine continues processing it until one of the following events occurs:
The
task completes, returns data (if any), metadata and statuses to
the client. When the task completes, it appears in the sp_sysmon section Task Context
Switches Due To
as Network
Packet Received.
If an Adaptive Server engine does not find any runnable tasks, it can either relinquish the CPU to the operating system or continue to look for a task to run by looping for the number of times set by runnable process search count.
Adaptive Server engines attempt to remain scheduled for the processor as long as possible. The engine runs until it is emptied by the operating system. However, if there is insufficient work available, the engine checks I/O and runnable tasks.
The task runs for a configurable period of time
and reaches a yield point Voluntary Yields
in sp_sysmon).
The task relinquishes the engine, and the next process in the queue
starts to run. “Scheduling client task processing time” discusses in more detail how
this works.
When you execute sp_who on a single-CPU system with multiple active tasks, sp_who output shows only a single task as “running”—it is the sp_who task itself. All other tasks in the run queue have the status “runnable.” The sp_who output also shows the cause for any sleeping tasks.
Figure 3-4 also shows the sleep queue with two sleeping tasks, as well as other objects in shared memory. Tasks are put to sleep while they wait for resources or for the results of a disk I/O operation.
Figure 3-4: Tasks queue up for the Adaptive Server engine