Initializes a previously allocated context structure.
#include <nks/thread.h> int NXContextReinit ( NXContext_t ctx, void (*start_routine)(void *arg), void *arg, int priority, unsigned long flags);
(IN) Points to the context to be initialized.
(IN) Points to the start function to be executed.
(IN) Points to the parameter for start_routine.
(IN) Specifies the priority of the context:
(IN) Specifies the context flags:
If successful, returns 0; otherwise, returns a nonzero error code:
NXContextReinit can be called to modify any of the attributes of a previously allocated context structure—except the stack size (see NXContextAlloc). The specified context must be idle because it is illegal to call NXContextReinit on a context that is currently being hosted by a thread.
To allocate a context for the ctx parameter, you must call NXContextAlloc.
NXContextReinit performs the following actions as part of initialization:
All active key/value pairs that are associated with the context are cleaned up. The destructor associated with each allocated key is called and the value associated with the key is set to NULL. All values associated with keys of the context being reset are lost.
The context's stack is reset to the state it was in when the context was created.
You can call NXContextReinit to change an existing context's type to either NX_CTX_NORMAL or NX_CTX_WORK.
For sample code, see ThrDestr.c.