2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2021-03-08 22:39:04 +01:00
|
|
|
* sched/group/group_childstatus.c
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2024-09-11 13:45:11 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2020-05-16 17:06:29 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-23 00:42:51 +01:00
|
|
|
* Included Files
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2013-01-23 23:23:46 +01:00
|
|
|
#include <sched.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2013-01-23 00:42:51 +01:00
|
|
|
#include <errno.h>
|
2013-01-23 23:23:46 +01:00
|
|
|
#include <debug.h>
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2014-08-09 01:53:55 +02:00
|
|
|
#include "sched/sched.h"
|
2014-08-08 22:06:42 +02:00
|
|
|
#include "group/group.h"
|
2013-01-23 00:42:51 +01:00
|
|
|
|
|
|
|
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-23 23:23:46 +01:00
|
|
|
* Pre-processor Definitions
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2019-10-24 18:49:28 +02:00
|
|
|
|
2013-01-23 23:23:46 +01:00
|
|
|
#if !defined(CONFIG_PREALLOC_CHILDSTATUS) || CONFIG_PREALLOC_CHILDSTATUS == 0
|
|
|
|
# undef CONFIG_PREALLOC_CHILDSTATUS
|
2021-06-15 10:45:40 +02:00
|
|
|
# define CONFIG_PREALLOC_CHILDSTATUS 16
|
2013-01-23 23:23:46 +01:00
|
|
|
#endif
|
|
|
|
|
2016-06-12 00:42:42 +02:00
|
|
|
#ifndef CONFIG_DEBUG_INFO
|
2013-01-23 23:23:46 +01:00
|
|
|
# undef CONFIG_DEBUG_CHILDSTATUS
|
|
|
|
#endif
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-23 23:23:46 +01:00
|
|
|
* Private Types
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2019-10-24 18:49:28 +02:00
|
|
|
|
2013-01-23 23:23:46 +01:00
|
|
|
/* Globals are maintained in a structure to minimize name collisions. */
|
|
|
|
|
2013-01-23 00:42:51 +01:00
|
|
|
struct child_pool_s
|
|
|
|
{
|
2013-01-23 23:23:46 +01:00
|
|
|
struct child_status_s alloc[CONFIG_PREALLOC_CHILDSTATUS];
|
2013-01-23 00:42:51 +01:00
|
|
|
FAR struct child_status_s *freelist;
|
|
|
|
};
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-23 00:42:51 +01:00
|
|
|
* Private Data
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
|
|
|
static struct child_pool_s g_child_pool;
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-23 00:42:51 +01:00
|
|
|
* Private Functions
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_dump_children
|
2013-01-23 23:23:46 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump all of the children when the part TCB list is modified.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-26 18:28:20 +01:00
|
|
|
* group - The task group containing the child status.
|
2013-01-23 23:23:46 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 23:23:46 +01:00
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called early in initialization. No special precautions are required.
|
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 23:23:46 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_CHILDSTATUS
|
2020-05-16 17:06:29 +02:00
|
|
|
static void group_dump_children(FAR struct task_group_s *group,
|
|
|
|
FAR const char *msg)
|
2013-01-23 23:23:46 +01:00
|
|
|
{
|
|
|
|
FAR struct child_status_s *child;
|
|
|
|
int i;
|
|
|
|
|
2016-06-16 20:33:32 +02:00
|
|
|
_info("Task group=%p: %s\n", group, msg);
|
2013-01-25 18:23:38 +01:00
|
|
|
for (i = 0, child = group->tg_children; child; i++, child = child->flink)
|
2013-01-23 23:23:46 +01:00
|
|
|
{
|
2016-06-16 20:33:32 +02:00
|
|
|
_info(" %d. ch_flags=%02x ch_pid=%d ch_status=%d\n",
|
2017-08-15 01:19:27 +02:00
|
|
|
i, child->ch_flags, child->ch_pid, child->ch_status);
|
2013-01-23 23:23:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2020-05-16 17:06:29 +02:00
|
|
|
# define group_dump_children(t,m)
|
2013-01-23 23:23:46 +01:00
|
|
|
#endif
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-23 00:42:51 +01:00
|
|
|
* Public Functions
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-23 00:42:51 +01:00
|
|
|
* Name: task_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize task related status. At present, this includes only the
|
|
|
|
* initialize of the child status pool.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-23 00:42:51 +01:00
|
|
|
* None.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 00:42:51 +01:00
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2013-01-23 23:23:46 +01:00
|
|
|
* Called early in initialization. No special precautions are required.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
|
|
|
void task_initialize(void)
|
|
|
|
{
|
|
|
|
FAR struct child_status_s *curr;
|
|
|
|
FAR struct child_status_s *prev;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Save all of the child status structures in a free list */
|
|
|
|
|
|
|
|
prev = &g_child_pool.alloc[0];
|
|
|
|
g_child_pool.freelist = prev;
|
2013-01-23 23:23:46 +01:00
|
|
|
for (i = 0; i < CONFIG_PREALLOC_CHILDSTATUS; i++)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
2013-01-23 23:23:46 +01:00
|
|
|
curr = &g_child_pool.alloc[i];
|
2013-01-23 00:42:51 +01:00
|
|
|
prev->flink = curr;
|
2013-01-23 23:23:46 +01:00
|
|
|
prev = curr;
|
2013-01-23 00:42:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_alloc_child
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Allocate a child status structure by removing the next entry from a
|
|
|
|
* free list.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-23 00:42:51 +01:00
|
|
|
* None.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 00:42:51 +01:00
|
|
|
* On success, a non-NULL pointer to a child status structure. NULL is
|
2021-07-15 11:00:13 +02:00
|
|
|
* returned when memory allocation fails.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called during task creation in a safe context. No special precautions
|
|
|
|
* are required here.
|
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
FAR struct child_status_s *group_alloc_child(void)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
|
|
|
FAR struct child_status_s *ret;
|
|
|
|
|
|
|
|
/* Return the status block at the head of the free list */
|
|
|
|
|
|
|
|
ret = g_child_pool.freelist;
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
g_child_pool.freelist = ret->flink;
|
2013-01-23 23:23:46 +01:00
|
|
|
ret->flink = NULL;
|
2013-01-23 00:42:51 +01:00
|
|
|
}
|
2021-07-15 11:00:13 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = kmm_zalloc(sizeof(*ret));
|
|
|
|
}
|
2013-01-23 00:42:51 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_free_child
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Release a child status structure by returning it to a free list.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-23 00:42:51 +01:00
|
|
|
* status - The child status structure to be freed.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 00:42:51 +01:00
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called during task creation in a safe context. No special precautions
|
|
|
|
* are required here.
|
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
void group_free_child(FAR struct child_status_s *child)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
|
|
|
/* Return the child status structure to the free list */
|
|
|
|
|
|
|
|
if (child)
|
|
|
|
{
|
2013-01-23 23:23:46 +01:00
|
|
|
child->flink = g_child_pool.freelist;
|
2013-01-23 00:42:51 +01:00
|
|
|
g_child_pool.freelist = child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_add_child
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2013-01-23 23:23:46 +01:00
|
|
|
* Add a child status structure in the given TCB.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-26 18:28:20 +01:00
|
|
|
* group - The task group for the child status.
|
2013-01-23 23:23:46 +01:00
|
|
|
* child - The structure to be added
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 23:23:46 +01:00
|
|
|
* N
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called during task creation processing in a safe context. No special
|
|
|
|
* precautions are required here.
|
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
void group_add_child(FAR struct task_group_s *group,
|
|
|
|
FAR struct child_status_s *child)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
2013-01-23 23:23:46 +01:00
|
|
|
/* Add the entry into the TCB list of children */
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2013-01-25 18:23:38 +01:00
|
|
|
child->flink = group->tg_children;
|
|
|
|
group->tg_children = child;
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
group_dump_children(group, "group_add_child");
|
2013-01-23 00:42:51 +01:00
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_find_child
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2013-01-26 18:28:20 +01:00
|
|
|
* Find a child status structure in the given task group. A reference to
|
2013-08-27 17:40:19 +02:00
|
|
|
* the child structure is returned, but the child remains in the group's
|
2013-01-26 18:28:20 +01:00
|
|
|
* list of children.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-26 18:28:20 +01:00
|
|
|
* group - The ID of the parent task group to containing the child status.
|
2013-01-23 00:42:51 +01:00
|
|
|
* pid - The ID of the child to find.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 00:42:51 +01:00
|
|
|
* On success, a non-NULL pointer to a child status structure. NULL is
|
|
|
|
* returned if there is child status structure for that pid in the TCB.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2020-05-16 17:06:29 +02:00
|
|
|
* Called during SIGCHLD processing in a safe context. No special
|
|
|
|
* precautions are required here.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
FAR struct child_status_s *group_find_child(FAR struct task_group_s *group,
|
|
|
|
pid_t pid)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
|
|
|
FAR struct child_status_s *child;
|
|
|
|
|
2013-01-26 18:28:20 +01:00
|
|
|
DEBUGASSERT(group);
|
|
|
|
|
2013-01-23 00:42:51 +01:00
|
|
|
/* Find the status structure with the matching PID */
|
|
|
|
|
2013-01-25 18:23:38 +01:00
|
|
|
for (child = group->tg_children; child; child = child->flink)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
|
|
|
if (child->ch_pid == pid)
|
|
|
|
{
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_exit_child
|
2013-01-25 00:18:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2020-05-16 17:06:29 +02:00
|
|
|
* Search for any child that has exited.
|
2013-01-25 00:18:32 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-25 00:18:32 +01:00
|
|
|
* tcb - The TCB of the parent task to containing the child status.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-25 00:18:32 +01:00
|
|
|
* On success, a non-NULL pointer to a child status structure for the
|
|
|
|
* exited child. NULL is returned if not child has exited.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2020-05-16 17:06:29 +02:00
|
|
|
* Called during SIGCHLD processing in a safe context. No special
|
|
|
|
* precautions are required here.
|
2013-01-25 00:18:32 +01:00
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-25 00:18:32 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
FAR struct child_status_s *group_exit_child(FAR struct task_group_s *group)
|
2013-01-25 00:18:32 +01:00
|
|
|
{
|
|
|
|
FAR struct child_status_s *child;
|
|
|
|
|
2013-01-25 01:01:08 +01:00
|
|
|
/* Find the status structure of any child task that has exitted. */
|
2013-01-25 00:18:32 +01:00
|
|
|
|
2013-01-25 18:23:38 +01:00
|
|
|
for (child = group->tg_children; child; child = child->flink)
|
2013-01-25 00:18:32 +01:00
|
|
|
{
|
|
|
|
if ((child->ch_flags & CHILD_FLAG_EXITED) != 0)
|
|
|
|
{
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_remove_child
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2013-01-26 18:28:20 +01:00
|
|
|
* Remove one child structure from a task group. The child is removed, but
|
2020-05-16 17:06:29 +02:00
|
|
|
* is not yet freed. group_free_child must be called in order to free the
|
2013-01-26 18:28:20 +01:00
|
|
|
* child status structure.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-26 18:28:20 +01:00
|
|
|
* group - The task group containing the child status.
|
2013-01-23 00:42:51 +01:00
|
|
|
* pid - The ID of the child to find.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 00:42:51 +01:00
|
|
|
* On success, a non-NULL pointer to a child status structure. NULL is
|
|
|
|
* returned if there is child status structure for that pid in the TCB.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2020-05-16 17:06:29 +02:00
|
|
|
* Called during SIGCHLD processing in a safe context. No special
|
|
|
|
* precautionsare required here.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
FAR struct child_status_s *group_remove_child(FAR struct task_group_s *group,
|
|
|
|
pid_t pid)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
|
|
|
FAR struct child_status_s *curr;
|
|
|
|
FAR struct child_status_s *prev;
|
|
|
|
|
2013-01-26 18:28:20 +01:00
|
|
|
DEBUGASSERT(group);
|
|
|
|
|
|
|
|
/* Find the status structure with the matching PID */
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2013-01-25 18:23:38 +01:00
|
|
|
for (prev = NULL, curr = group->tg_children;
|
2013-01-23 00:42:51 +01:00
|
|
|
curr;
|
|
|
|
prev = curr, curr = curr->flink)
|
|
|
|
{
|
|
|
|
if (curr->ch_pid == pid)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-26 18:28:20 +01:00
|
|
|
/* Did we find it? If so, remove it from the group. */
|
2013-01-23 00:42:51 +01:00
|
|
|
|
|
|
|
if (curr)
|
|
|
|
{
|
|
|
|
/* Do we remove it from mid-list? Or from the head of the list? */
|
|
|
|
|
|
|
|
if (prev)
|
|
|
|
{
|
|
|
|
prev->flink = curr->flink;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-25 18:23:38 +01:00
|
|
|
group->tg_children = curr->flink;
|
2013-01-23 00:42:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
curr->flink = NULL;
|
2020-05-16 17:06:29 +02:00
|
|
|
group_dump_children(group, "group_remove_child");
|
2013-01-23 00:42:51 +01:00
|
|
|
}
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2013-01-23 00:42:51 +01:00
|
|
|
return curr;
|
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2020-05-16 17:06:29 +02:00
|
|
|
* Name: group_remove_children
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2013-01-26 18:28:20 +01:00
|
|
|
* Remove and free all child structure from the task group.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-26 18:28:20 +01:00
|
|
|
* group - The task group containing the child status.
|
2013-01-23 00:42:51 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-23 00:42:51 +01:00
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Called during task exit processing in a safe context. No special
|
|
|
|
* precautions are required here.
|
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2020-05-16 17:06:29 +02:00
|
|
|
void group_remove_children(FAR struct task_group_s *group)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
|
|
|
FAR struct child_status_s *curr;
|
|
|
|
FAR struct child_status_s *next;
|
|
|
|
|
2020-05-16 18:05:46 +02:00
|
|
|
/* Remove all child structures for the TCB and return them to the
|
|
|
|
* freelist.
|
|
|
|
*/
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2013-01-25 18:23:38 +01:00
|
|
|
for (curr = group->tg_children; curr; curr = next)
|
2013-01-23 00:42:51 +01:00
|
|
|
{
|
|
|
|
next = curr->flink;
|
2020-05-16 17:06:29 +02:00
|
|
|
group_free_child(curr);
|
2013-01-23 00:42:51 +01:00
|
|
|
}
|
2013-01-23 23:23:46 +01:00
|
|
|
|
2013-01-25 18:23:38 +01:00
|
|
|
group->tg_children = NULL;
|
2020-05-16 17:06:29 +02:00
|
|
|
group_dump_children(group, "group_remove_children");
|
2013-01-23 00:42:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_SCHED_HAVE_PARENT && CONFIG_SCHED_CHILD_STATUS */
|