mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
sched/tcb: add free tcb flag to support static tcb
Add support for static tcb, applications in some special case can initialize system resources in advance through static tcb. | static struct task_tcb_s g_tcb; | | memset(&g_tcb, 0, sizeof(struct task_tcb_s)); | g_tcb.cmn.flags = TCB_FLAG_TTYPE_KERNEL; | nxtask_init(&g_tcb, "PTCB", 101, NULL, 1024, ptcb_task, NULL, NULL, NULL); | | ... | nxtask_activate(&g_tcb.cmn); Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
@@ -163,7 +163,10 @@ int nxsched_release_tcb(FAR struct tcb_s *tcb, uint8_t ttype)
|
||||
|
||||
/* And, finally, release the TCB itself */
|
||||
|
||||
kmm_free(tcb);
|
||||
if (tcb->flags & TCB_FLAG_FREE_TCB)
|
||||
{
|
||||
kmm_free(tcb);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -91,7 +91,7 @@ int nxthread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
|
||||
/* Setup the task type */
|
||||
|
||||
tcb->cmn.flags = ttype;
|
||||
tcb->cmn.flags = ttype | TCB_FLAG_FREE_TCB;
|
||||
|
||||
/* Initialize the task */
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ static int nxtask_spawn_create(FAR const char *name, int priority,
|
||||
|
||||
/* Setup the task type */
|
||||
|
||||
tcb->cmn.flags = TCB_FLAG_TTYPE_TASK;
|
||||
tcb->cmn.flags = TCB_FLAG_TTYPE_TASK | TCB_FLAG_FREE_TCB;
|
||||
|
||||
/* Initialize the task */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user