Scheduling client task processing time

The time slice configuration parameter prevents executing tasks from monopolizing engines during execution. The scheduler allows a task to execute on an Adaptive Server engine for a maximum amount of time that is equal to the time slice and cpu grace time values combined, using default times for time slice (100 milliseconds, 1/10 of a second, or equivalent to one clock tick) and cpu grace time (500 clock ticks, or 50 seconds).

Adaptive Server’s scheduler does not force tasks off an Adaptive Server engine. Tasks voluntarily relinquish the engine at a yield point, when the task does not hold a vital resource such as a spinlock.

Each time the task comes to a yield point, it checks to see if time slice has been exceeded. If it has not, the task continues to execute. If execution time does exceed time slice, the task voluntarily relinquishes the engine within the cpu grace time interval and the next task in the run queue begins executing.

The default value for the time slice parameter is 100 clock milliseconds, and there is seldom any reason to change it. The default value for cpu grace time is 500 clock ticks. If time slice is set too low, an engine may spend too much time switching between tasks, which tends to increase response time.

If time slice is set too high, CPU-intensive processes may monopolize the CPU, which can increase response time for short tasks. If your applications encounter time slice errors, adjust cpu grace time, not time slice.

See Chapter 4, “Distributing Engine Resources,” for more information.

Use sp_sysmon to determine how many times tasks yield voluntarily.

If you want to increase the amount of time that CPU-intensive applications run on an engine before yielding, you can assign execution attributes to specific logins, applications, or stored procedures.

If the task has to relinquish the engine before fulfilling the client request, it goes to the end of the run queue, unless there are no other tasks in the run queue. If no tasks are in the run queue when an executing task reaches a yield point during grace time, Adaptive Server grants the task another processing interval.

If no other tasks are in the run queue, and the engine still has CPU time, Adaptive Server continues to grant time slice intervals to the task until it completes.

Normally, tasks relinquish the engine at yield points prior to completion of the cpu grace time interval. It is possible for a task not to encounter a yield point and to exceed the time slice interval. When the cpu grace time ends, Adaptive Server terminates the task with a time slice error. If you receive a time slice error, try doubling the value of cpu grace time. If the problem persists, call Sybase Technical Support.