sched/task/task_init.c: Add nxtask_uninit()
Add trivial function nxtask_uninit(). This function will undo all operations on a TCB performed by task_init() and release the TCB by calling kmm_free(). This is intended primarily to support error recovery operations after a successful call to task_init() such was when a subsequent call to task_activate fails. That error recovery is trivial but not obvious. This helper function should eliminate confusion about what to do to recover after calling nxtask_init()
This commit is contained in:
parent
d2f10e7386
commit
b9042f5900
@ -944,6 +944,27 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||
FAR uint32_t *stack, uint32_t stack_size, main_t entry,
|
||||
FAR char * const argv[]);
|
||||
|
||||
/********************************************************************************
|
||||
* Name: nxtask_uninit
|
||||
*
|
||||
* Description:
|
||||
* Undo all operations on a TCB performed by task_init() and release the
|
||||
* TCB by calling kmm_free(). This is intended primarily to support
|
||||
* error recovery operations after a successful call to task_init() such
|
||||
* was when a subsequent call to task_activate fails.
|
||||
*
|
||||
* Caution: Freeing of the TCB itself might be an unexpected side-effect.
|
||||
*
|
||||
* Input Parameters:
|
||||
* tcb - Address of the TCB initialized by task_init()
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; negative error value on failure appropriately.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
void nxtask_uninit(FAR struct tcb_s *tcb);
|
||||
|
||||
/********************************************************************************
|
||||
* Name: nxtask_activate
|
||||
*
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <sched.h>
|
||||
#include <queue.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
@ -74,8 +75,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||
FAR uint32_t *stack, uint32_t stack_size,
|
||||
main_t entry, FAR char * const argv[])
|
||||
FAR uint32_t *stack, uint32_t stack_size,
|
||||
main_t entry, FAR char * const argv[])
|
||||
{
|
||||
FAR struct task_tcb_s *ttcb = (FAR struct task_tcb_s *)tcb;
|
||||
int ret;
|
||||
@ -136,3 +137,38 @@ errout_with_group:
|
||||
errout:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtask_uninit
|
||||
*
|
||||
* Description:
|
||||
* Undo all operations on a TCB performed by task_init() and release the
|
||||
* TCB by calling kmm_free(). This is intended primarily to support
|
||||
* error recovery operations after a successful call to task_init() such
|
||||
* was when a subsequent call to task_activate fails.
|
||||
*
|
||||
* Caution: Freeing of the TCB itself might be an unexpected side-effect.
|
||||
*
|
||||
* Input Parameters:
|
||||
* tcb - Address of the TCB initialized by task_init()
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; negative error value on failure appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxtask_uninit(FAR struct tcb_s *tcb)
|
||||
{
|
||||
/* The TCB was added to the inactive task list by
|
||||
* nxtask_setup_scheduler().
|
||||
*/
|
||||
|
||||
dq_rem((FAR dq_entry_t *)tcb, (FAR dq_queue_t *)&g_inactivetasks);
|
||||
|
||||
/* Release all resources associated with the TCB... Including the TCB
|
||||
* itself.
|
||||
*/
|
||||
|
||||
nxsched_release_tcb((FAR struct tcb_s *)tcb,
|
||||
tcb->flags & TCB_FLAG_TTYPE_MASK);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user