On Unix, a task is executed directly on an operating system thread. On these platforms, the value of the -gn option sets the number of operating system threads created when the database server starts; all tasks are serviced from this set of threads. When a thread becomes available, it picks up the next available task that requires processing. Once processing a task, a thread remains with that task until it has been completed. If the task needs to block for some reason, perhaps because it is pending an I/O operation, or while waiting for a lock, the thread voluntarily relinquishes control of the CPU back to the operating system scheduler allowing other threads to run on that CPU.
In addition to voluntarily relinquishing the CPU, a thread may be preempted by the operating system scheduler. Each application thread within a process is given a series of time slices in which to run, the length of which is determined by its priority and other system factors. When a thread reaches the end of its current time slice it is preempted by the operating system and scheduled to run again at a later time. The operating system scheduler then chooses another thread to execute for a time slice. This preemptive scheduling does not affect the processing of tasks in any visible way; when a thread is scheduled to run again, the task is picked up at the point where it left off.
Once processing of the active task is completed, the thread checks to see if any other tasks have come available for processing. If so, it picks up the next available task and continues. Otherwise, it relinquishes the CPU and waits for a new task to arrive at the database server.
|Send feedback about this page via email or DocCommentXchange||Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0|