mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 10:03:34 +08:00
Add framework to support task groups
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5562 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -108,6 +108,7 @@ static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
{
|
||||
FAR _TCB *tcb;
|
||||
pid_t pid;
|
||||
int errcode;
|
||||
int ret;
|
||||
|
||||
/* Allocate a TCB for the new task. */
|
||||
@@ -115,15 +116,28 @@ static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
tcb = (FAR _TCB*)kzalloc(sizeof(_TCB));
|
||||
if (!tcb)
|
||||
{
|
||||
errcode = ENOMEM;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Create a new task group */
|
||||
|
||||
#ifdef HAVE_TASK_GROUP
|
||||
ret = group_create(tcb);
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Associate file descriptors with the new task */
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
ret = sched_setuptaskfiles(tcb);
|
||||
if (ret != OK)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
#endif
|
||||
@@ -138,6 +152,7 @@ static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
ret = up_create_stack(tcb, stack_size);
|
||||
if (ret != OK)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
#endif
|
||||
@@ -147,6 +162,7 @@ static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
ret = task_schedsetup(tcb, priority, task_start, entry, ttype);
|
||||
if (ret != OK)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
|
||||
@@ -163,6 +179,8 @@ static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
ret = task_activate(tcb);
|
||||
if (ret != OK)
|
||||
{
|
||||
errcode = get_errno();
|
||||
|
||||
/* The TCB was added to the active task list by task_schedsetup() */
|
||||
|
||||
dq_rem((FAR dq_entry_t*)tcb, (dq_queue_t*)&g_inactivetasks);
|
||||
@@ -175,7 +193,7 @@ errout_with_tcb:
|
||||
sched_releasetcb(tcb);
|
||||
|
||||
errout:
|
||||
errno = ENOMEM;
|
||||
set_errno(errcode);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user