Training
×

Thread Creation

Thread priority ranges from 0 to 254 with 0 being the highest priority.
The thread start address tells INtime where to start execution. This is usually specified as the name of the C function that contains the thread.
The stack size must be at least 4096 bytes (internally always a multiple of 4K is allocated).
The fourth parameter is passed to the newly created thread and can be used to pass any 32-bit value; a type-cast is typically required.
If this call succeeds, it’s return value is a thread handle, a 16-bit number that is returned by the operating system to uniquely identify this thread. This thread handle can be used to identify this thread in other calls which may be issued to manipulate this thread. The thread handle indirectly points to a data structure (thread descriptor) that is maintained by INtime to store information about the thread. If a thread wants to refer to itself, it can use NULL_RTHANDLE as the value for the thread handle.
If this call fails, it returns BAD_RTHANDLE; GetLastRtError may be used to determine the exception code (thread specific).
A newly created thread pre-empts its creator if the new thread has a higher priority.