Once started, the preemptive scheduling can be deactivated by calling tce_preempt_off. During a program execution preemptiveness can be switched on and off freely.
-
To implement the preemptive execution TCE uses two signals -- the clock signal and the IO signal (SIGALRM and SIGIO on Unix-like Operating Systems). When one of those signals is generated, the current execution context is preempted, and the control is transferred to appropriate signal handler. The handler, then, either calculates the time used by the currently running thread (clock) or inspects IO descriptors. When any of these activities transferred a higher priority thread into the ready
state, the context switch takes place.
-
Since the preemptive scheduling can change threads' contexts any time, the application should guard its critical sections by TCE semaphores. This way, a desired order of execution can be assured.
|