Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Prior to calling nxtask_init(), the TCB  can be freed using the kmm allocator, specifically the function kmm_free().  However, after nxtask_init() is called, additional resources will be associated with the TCB and you must then call nxtask_uninit() to free the TCB and all of its associated resources.  kmm_free() will be used internally by nxtask_uninit() to free the TCB.  Note that in any event, the TCB must be allocated with one of the kmm_malloc() allocation functions.

You must never free the TCB after nxtask_activate() returns successfully.

Freeing the Custom Stack Memory

...

If TCB_FLAG_CUSTOM_STACK were not set in the TCB flags, the OS would attempt to free the stack using kmm_free() which is probably not what you want in this case.

You must not free the stack after nxtask_activate() returns successfully and until the kernel thread is terminated.