Threads and Semaphores: 4.2 Using Multiple Threads: Managing Priority Values

Up: GEOS SDK TechDocs | Up | Prev: 4.1 How GEOS Threads Are Created | Next: 4.3 Handling Errors in a Thread
ThreadGetInfo(), ThreadModify(), ThreadGetInfoType

You can ascertain and modify the priority of any thread in the system, given the thread's handle. The handle is provided by the routines that create threads, and it can be provided by one thread to another in a message. The following system routines relate to the priority of a thread:

ThreadGetInfo() returns information about a thread. When calling ThreadGetInfo() , pass the handle of the thread in question and a value of the type ThreadGetInfoType (see below). If zero is passed as the thread handle, ThreadGetInfo() returns information on whatever thread executed the call.

ThreadGetInfoType is an enumerated type with three possible values:

TGIT_PRIORITY_AND_USAGE
This requests the base priority and recent CPU usage of a thread. (To determine the current priority, simply add the base priority to the recent CPU usage.)
TGIT_THREAD_HANDLE
This requests the handle of the thread. Use this (with a thread handle of zero) to get the caller's own thread handle.
TGIT_QUEUE_HANDLE
This requests the handle of the event queue for an event-driven thread. It returns a zero handle if the thread is not event-driven.

T hreadModify() changes the priority of a thread. The arguments to pass include the handle of the thread to modify (zero for the thread executing the call), a new base priority for the thread, and two flags: One that indicates whether to change the thread's base priority and one that indicates whether to reset the thread's recent CPU usage to zero. If the flag to change the thread's base priority is not set, the new base priority argument is ignored. In general, you should only lower a thread's priority (i.e., raise its base priority number). Applications that raise their own priority damage the performance of the system as a whole. Keep in mind that GEOS already favors the thread with which the user is interacting.

There are several pre-defined priority levels you can use to set a thread's priority. You may wish to use these when debugging to raise the priority of a potentially buggy thread for efficient debugging. These are listed below, each a different constant.


Up: GEOS SDK TechDocs | Up | Prev: 4.1 How GEOS Threads Are Created | Next: 4.3 Handling Errors in a Thread