Contents
KosThreadCreate()
This function is declared in the kos/thread.h
file.
Retcode KosThreadCreate(Tid *tid,
rtl_uint32_t priority,
rtl_uint32_t stackSize,
ThreadRoutine routine,
void *context,
int suspended);
This function creates a new thread.
Input parameters:
priority
must be within the interval from 0 to 31; the following priority constants are available:ThreadPriorityLowest
(0),ThreadPriorityNormal
(15) andThreadPriorityHighest
(31).stackSize
is the size of the stack.routine
is the function that will be executed in the thread.context
is the argument that will be passed to theroutine
function.suspended
lets you create a thread in the suspended state (1 means create suspended, 0 means create not suspended).
Output parameters:
tid
is the ID of the created thread.
Example
int main(int argc, char **argv)
{
Tid tidB;
Tid tidC;
Retcode rcB;
Retcode rcC;
static ThreadContext threadContext[] = {
{.ddi = "B", .deviceName = "/pci/bus0/dev2/fun0/DDI_B"},
{.ddi = "C", .deviceName = "/pci/bus0/dev2/fun0/DDI_C"},
};
rcB = KosThreadCreate(&tidB, ThreadPriorityNormal,
ThreadStackSizeDefault,
FbHotplugThread,
&threadContext[0], 0);
if (rcB != rcOk)
ERR("Failed to start thread %s", threadContext[0].ddi);
rcC = KosThreadCreate(&tidC, ThreadPriorityNormal,
ThreadStackSizeDefault,
FbHotplugThread,
&threadContext[1], 0);
if (rcC != rcOk)
ERR("Failed to start thread %s", threadContext[1].ddi);
/* Waiting for the threads to complete */
...
}