INtime SDK Help
CreateRtThread
INtime SDK v6 > About INtime > INtime Kernel > Threads > CreateRtThread

Creates a thread to execute within the context of the calling process.

RTHANDLE CreateRtThread(
    BYTE byPriority,      // thread initial priority
    LPPROC lpEntry,       // pointer to thread entry point
    DWORD dwStackSize,    // size of new thread's stack
    LPVOID lpParam        // thread parameter
);

Parameters

byPriority
Specifies the new thread's initial priority.
0 The maximum allowable priority of the calling thread's process.
1-254 The new thread's priority; this must not exceed the maximum allowable priority of the calling thread's process.
lpEntry
A pointer to the new thread's entry point. The function indicated by lpEntry is of the form:
void ThreadFunc(LPVOID lpParam)
{
}

dwStackSize
The number of bytes to allocate to the new thread's stack. Any value provided will be rounded up to a multiple of 4096 bytes (the CPU page size).
lpParam
This parameter is passed through to the thread function.

Remarks

CreateRtThread creates a new thread which starts executing at the function indicated by lpEntry. If the current process references any RSLs then the RSL entry routine is called before the thread function is executed with a reason code of RSL_THREAD_ATTACH. If the thread returns from the thread function then it deletes itself by calling DeleteRtThread.

Return Values

A handle for the new thread.
Success.
BAD_RTHANDLE
Failure. To determine the status, call GetLastRtError.

Status

E_OK 0x0000
No exceptional conditions occurred.
E_MEM 0x0002
The calling thread's process cannot create a thread as specified with the memory available.
E_LIMIT 0x0004
One or more of these conditions exist:
  • The calling thread's process already reached its object or thread limit.
  • byPriority contains a value other than 0 (zero) and greater (numerically smaller) than the maximum allowable priority for threads in the calling thread's process.
E_SLOT 0x000C
You cannot create more RT objects because the GDT's slots are full.
E_PARAM 0x8004
A stack size of 0 was specified.
E_BAD_ADDR 0x800F
The pointer to lpEntry is invalid. One of these conditions exist:
  • All or part of lpEntry is outside the calling thread's virtual address space.
  • The virtual address space has no associated physical memory.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/rtbase.h rt.h rt.lib
See Also

Processes