6.7 void rtkThreadAdd(struct Thread *t, struct Queue *q, void *SP, void (*start)(void *), void *param)

This function adds threads in addition to the one initialized by rtkInitialize. Parameter t is a pointer to an struct Thread object. Each thread must have its own unique struct Thread object. Parameter q is the priority queue to which this thread belongs to. SP points to the starting point of the stack for this thread. Parameter start is a function that marks the starting point of this new thread. param is a void pointer that is `passed' to the parameter of `start'. This allows different instances of the same thread function receive different parameters.

If you declare the stack for this thread as char stack1[64], you should pass stack1+sizeof(stack1) as parameter SP.

Note that this call may immediately cause the calling thread to yield to the new thread if the new thread has a higher priority.



Copyright © 2008-10-25 by Tak Auyeung