Compartilhar via


Setting the Thread Quantum (Windows CE 5.0)

Send Feedback

As a preemptive multitasking operating system, Windows CE bases preemption solely on the priority of the thread; that is, Windows CE schedules threads with a higher priority to run first. Threads at the same priority level run in a round-robin fashion with each thread receiving a quantum, or slice, of execution time.

Because Windows CE enables an application to set the quantum on a thread-by-thread basis, you can adapt the scheduler to the current needs of your application. To adjust the quantum, Windows CE provides two functions:

Altering the quantum for a specified thread does not affect threads with a higher priority. You can set the default thread quantum for the system with the dwDefaultThreadQuantum OAL variable. It must be set during the OEMInit phase of OAL initialization and must be greater than zero; otherwise, it is ignored. Setting this value too low or too high can have dramatic effects on OS performance. When the system starts, dwDefaultThreadQuantum is set to a default value of 100 milliseconds. If you want to change the default value, you must declare the value and change the default. The following code example shows this.

extern DWORD dwDefaultThreadQuantum;

void OEMInit()
{
...
   dwDefaultThreadQuantum = 75; // 75 milliseconds
...
}

See Also

Timer and Scheduling Management

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.