2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 22:06:42 +02:00
|
|
|
* sched/group/group_create.c
|
2013-01-25 18:23:38 +01:00
|
|
|
*
|
2019-08-02 18:01:30 +02:00
|
|
|
* Copyright (C) 2013, 2016, 2019 Gregory Nutt. All rights reserved.
|
2013-01-25 18:23:38 +01:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-25 18:23:38 +01:00
|
|
|
* Included Files
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-25 18:23:38 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sched.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
#include <nuttx/irq.h>
|
2013-01-25 18:23:38 +01:00
|
|
|
#include <nuttx/kmalloc.h>
|
2016-11-03 19:42:02 +01:00
|
|
|
#include <nuttx/semaphore.h>
|
2019-08-02 18:01:30 +02:00
|
|
|
#include <nuttx/sched.h>
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2014-08-08 21:53:29 +02:00
|
|
|
#include "environ/environ.h"
|
2019-08-06 22:13:43 +02:00
|
|
|
#include "sched/sched.h"
|
2014-09-03 22:58:24 +02:00
|
|
|
#include "group/group.h"
|
2013-01-26 00:21:27 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-25 18:23:38 +01:00
|
|
|
* Pre-processor Definitions
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2019-08-06 22:13:43 +02:00
|
|
|
|
2013-01-25 20:15:05 +01:00
|
|
|
/* Is this worth making a configuration option? */
|
|
|
|
|
|
|
|
#define GROUP_INITIAL_MEMBERS 4
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-25 18:23:38 +01:00
|
|
|
* Private Data
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2019-08-06 22:13:43 +02:00
|
|
|
|
2013-01-26 18:28:20 +01:00
|
|
|
/* This is counter that is used to generate unique task group IDs */
|
|
|
|
|
2014-08-26 22:54:39 +02:00
|
|
|
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
|
2019-08-02 18:01:30 +02:00
|
|
|
static grpid_t g_grpid_counter;
|
2013-01-26 18:28:20 +01:00
|
|
|
#endif
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-26 18:28:20 +01:00
|
|
|
* Public Data
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2014-08-26 22:54:39 +02:00
|
|
|
|
|
|
|
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
|
2013-01-26 18:28:20 +01:00
|
|
|
/* This is the head of a list of all group members */
|
|
|
|
|
|
|
|
FAR struct task_group_s *g_grouphead;
|
|
|
|
#endif
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-25 18:23:38 +01:00
|
|
|
* Private Functions
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2019-08-02 18:01:30 +02:00
|
|
|
* Name: group_assign_grpid
|
2013-01-26 18:28:20 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Create a unique group ID.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-26 18:28:20 +01:00
|
|
|
* tcb - The tcb in need of the task group.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-26 18:28:20 +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-26 18:28:20 +01:00
|
|
|
|
2014-08-26 22:54:39 +02:00
|
|
|
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
|
2019-08-02 18:01:30 +02:00
|
|
|
static void group_assign_grpid(FAR struct task_group_s *group)
|
2013-01-26 18:28:20 +01:00
|
|
|
{
|
|
|
|
irqstate_t flags;
|
2019-08-02 18:01:30 +02:00
|
|
|
grpid_t grpid;
|
2013-01-26 18:28:20 +01:00
|
|
|
|
2019-08-03 16:18:58 +02:00
|
|
|
/* Pre-emption should already be disabled, but let's be paranoid careful */
|
2013-01-26 18:28:20 +01:00
|
|
|
|
|
|
|
sched_lock();
|
|
|
|
|
|
|
|
/* Loop until we create a unique ID */
|
|
|
|
|
2015-10-08 03:59:14 +02:00
|
|
|
for (; ; )
|
2013-01-26 18:28:20 +01:00
|
|
|
{
|
2014-08-26 22:54:39 +02:00
|
|
|
/* Increment the ID counter. This is global data so be extra paranoid. */
|
2013-01-26 18:28:20 +01:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2019-08-02 18:01:30 +02:00
|
|
|
grpid = ++g_grpid_counter;
|
2013-01-26 18:28:20 +01:00
|
|
|
|
|
|
|
/* Check for overflow */
|
|
|
|
|
2019-08-02 18:01:30 +02:00
|
|
|
if (grpid <= 0)
|
2013-01-26 18:28:20 +01:00
|
|
|
{
|
2019-08-03 16:18:58 +02:00
|
|
|
g_grpid_counter = 1; /* One is the IDLE group */
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2013-01-26 18:28:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Does a task group with this ID already exist? */
|
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2019-08-02 18:01:30 +02:00
|
|
|
if (group_findby_grpid(grpid) == NULL)
|
2013-01-26 18:28:20 +01:00
|
|
|
{
|
2019-08-03 16:18:58 +02:00
|
|
|
/* No.. Assign this ID to the new group and return */
|
2013-01-26 18:28:20 +01:00
|
|
|
|
2019-08-02 18:01:30 +02:00
|
|
|
group->tg_grpid = grpid;
|
2013-01-26 18:28:20 +01:00
|
|
|
sched_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_GROUP_MEMBERS */
|
|
|
|
|
2019-08-06 22:13:43 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: group_inherit_identity
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* All inherit the user identity from the parent task group.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* group - The new task group.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The parent of the new task is the task at the head of the assigned task
|
|
|
|
* list for the current CPU.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_USER_IDENTITY
|
|
|
|
static inline void group_inherit_identity(FAR struct task_group_s *group)
|
|
|
|
{
|
|
|
|
FAR struct tcb_s *rtcb = this_task();
|
|
|
|
FAR struct task_group_s *rgroup = rtcb->group;
|
|
|
|
|
|
|
|
/* Inherit the user identity from the parent task group. */
|
|
|
|
|
|
|
|
DEBUGASSERT(group != NULL);
|
|
|
|
group->tg_uid = rgroup->tg_uid;
|
|
|
|
group->tg_gid = rgroup->tg_gid;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define group_inherit_identity(group)
|
|
|
|
#endif
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-25 18:23:38 +01:00
|
|
|
* Public Functions
|
2015-10-03 15:25:53 +02:00
|
|
|
****************************************************************************/
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-25 20:15:05 +01:00
|
|
|
* Name: group_allocate
|
2013-01-25 18:23:38 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2013-01-25 20:15:05 +01:00
|
|
|
* Create and a new task group structure for the specified TCB. This
|
|
|
|
* function is called as part of the task creation sequence. The structure
|
2014-09-03 21:49:35 +02:00
|
|
|
* allocated and zeroed, but otherwise uninitialized. The full creation
|
2013-01-25 20:15:05 +01:00
|
|
|
* of the group of a two step process: (1) First, this function allocates
|
|
|
|
* group structure early in the task creation sequence in order to provide a
|
|
|
|
* group container, then (2) group_initialize() is called to set up the
|
|
|
|
* group membership.
|
2013-01-25 18:23:38 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-09-03 22:58:24 +02:00
|
|
|
* tcb - The tcb in need of the task group.
|
|
|
|
* ttype - Type of the thread that is the parent of the group
|
2013-01-25 18:23:38 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-25 18:23:38 +01:00
|
|
|
* 0 (OK) on success; a negated errno value on failure.
|
|
|
|
*
|
|
|
|
* 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-25 18:23:38 +01:00
|
|
|
|
2014-09-03 22:58:24 +02:00
|
|
|
int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
|
2013-01-25 18:23:38 +01:00
|
|
|
{
|
2013-02-03 17:43:58 +01:00
|
|
|
FAR struct task_group_s *group;
|
2013-01-26 00:21:27 +01:00
|
|
|
int ret;
|
|
|
|
|
2013-02-04 23:38:59 +01:00
|
|
|
DEBUGASSERT(tcb && !tcb->cmn.group);
|
2013-01-25 20:15:05 +01:00
|
|
|
|
|
|
|
/* Allocate the group structure and assign it to the TCB */
|
|
|
|
|
2014-09-01 01:34:44 +02:00
|
|
|
group = (FAR struct task_group_s *)kmm_zalloc(sizeof(struct task_group_s));
|
2013-02-03 17:43:58 +01:00
|
|
|
if (!group)
|
2013-01-26 00:21:27 +01:00
|
|
|
{
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2014-08-29 22:47:22 +02:00
|
|
|
#if CONFIG_NFILE_STREAMS > 0 && (defined(CONFIG_BUILD_PROTECTED) || \
|
|
|
|
defined(CONFIG_BUILD_KERNEL)) && defined(CONFIG_MM_KERNEL_HEAP)
|
2014-09-03 21:49:35 +02:00
|
|
|
/* If this group is being created for a privileged thread, then all elements
|
|
|
|
* of the group must be created for privileged access.
|
|
|
|
*/
|
|
|
|
|
2014-09-03 22:58:24 +02:00
|
|
|
if ((ttype & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
|
2014-09-03 21:49:35 +02:00
|
|
|
{
|
|
|
|
group->tg_flags |= GROUP_FLAG_PRIVILEGED;
|
|
|
|
}
|
2013-03-11 14:21:33 +01:00
|
|
|
|
|
|
|
/* In a flat, single-heap build. The stream list is allocated with the
|
|
|
|
* group structure. But in a kernel build with a kernel allocator, it
|
|
|
|
* must be separately allocated using a user-space allocator.
|
2018-09-13 22:03:09 +02:00
|
|
|
*
|
|
|
|
* REVISIT: Kernel threads should not require a stream allocation. They
|
|
|
|
* should not be using C buffered I/O at all.
|
2013-03-11 14:21:33 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
group->tg_streamlist = (FAR struct streamlist *)
|
2014-09-03 21:49:35 +02:00
|
|
|
group_zalloc(group, sizeof(struct streamlist));
|
2013-03-11 14:21:33 +01:00
|
|
|
|
|
|
|
if (!group->tg_streamlist)
|
|
|
|
{
|
2014-09-01 01:04:02 +02:00
|
|
|
kmm_free(group);
|
2013-03-11 14:21:33 +01:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
/* Attach the group to the TCB */
|
|
|
|
|
2013-02-04 23:38:59 +01:00
|
|
|
tcb->cmn.group = group;
|
2013-02-03 17:43:58 +01:00
|
|
|
|
2014-08-26 22:54:39 +02:00
|
|
|
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
|
2019-08-02 18:01:30 +02:00
|
|
|
/* Assign the group a unique ID. If g_grpid_counter were to wrap before we
|
2013-01-26 18:28:20 +01:00
|
|
|
* finish with task creation, that would be a problem.
|
|
|
|
*/
|
|
|
|
|
2019-08-02 18:01:30 +02:00
|
|
|
group_assign_grpid(group);
|
2013-01-26 18:28:20 +01:00
|
|
|
#endif
|
|
|
|
|
2019-08-06 22:13:43 +02:00
|
|
|
/* Inherit the user identity from the parent task group */
|
|
|
|
|
|
|
|
group_inherit_identity(group);
|
|
|
|
|
2014-08-26 22:54:39 +02:00
|
|
|
/* Duplicate the parent tasks environment */
|
2013-01-26 00:21:27 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
ret = env_dup(group);
|
2013-01-26 00:21:27 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2014-08-29 22:47:22 +02:00
|
|
|
#if CONFIG_NFILE_STREAMS > 0 && (defined(CONFIG_BUILD_PROTECTED) || \
|
|
|
|
defined(CONFIG_BUILD_KERNEL)) && defined(CONFIG_MM_KERNEL_HEAP)
|
2014-09-03 21:49:35 +02:00
|
|
|
group_free(group, group->tg_streamlist);
|
2013-03-13 18:32:37 +01:00
|
|
|
#endif
|
2014-09-01 01:04:02 +02:00
|
|
|
kmm_free(group);
|
2013-02-04 23:38:59 +01:00
|
|
|
tcb->cmn.group = NULL;
|
2013-01-26 00:21:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-08-10 15:37:25 +02:00
|
|
|
#ifndef CONFIG_DISABLE_PTHREAD
|
2013-02-03 17:43:58 +01:00
|
|
|
/* Initialize the pthread join semaphore */
|
|
|
|
|
2017-10-03 20:51:15 +02:00
|
|
|
(void)nxsem_init(&group->tg_joinsem, 0, 1);
|
2013-02-03 17:43:58 +01:00
|
|
|
#endif
|
|
|
|
|
2016-08-10 15:37:25 +02:00
|
|
|
#if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT)
|
2016-11-03 19:42:02 +01:00
|
|
|
/* Initialize the exit/wait semaphores
|
|
|
|
*
|
|
|
|
* This semaphore is used for signaling and, hence, should not have
|
|
|
|
* priority inheritance enabled.
|
|
|
|
*/
|
2016-08-10 15:37:25 +02:00
|
|
|
|
2017-10-03 20:51:15 +02:00
|
|
|
(void)nxsem_init(&group->tg_exitsem, 0, 0);
|
2017-10-03 23:35:24 +02:00
|
|
|
(void)nxsem_setprotocol(&group->tg_exitsem, SEM_PRIO_NONE);
|
2016-08-10 15:37:25 +02:00
|
|
|
#endif
|
|
|
|
|
2013-01-26 00:21:27 +01:00
|
|
|
return OK;
|
2013-01-25 20:15:05 +01:00
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:53 +02:00
|
|
|
/****************************************************************************
|
2013-01-25 20:15:05 +01:00
|
|
|
* Name: group_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add the task as the initial member of the group. The full creation of
|
|
|
|
* the group of a two step process: (1) First, this group structure is
|
|
|
|
* allocated by group_allocate() early in the task creation sequence, then
|
|
|
|
* (2) this function is called to set up the initial group membership.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-01-25 20:15:05 +01:00
|
|
|
* tcb - The tcb in need of the task group.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-25 20:15:05 +01:00
|
|
|
* 0 (OK) on success; a negated errno value on failure.
|
|
|
|
*
|
|
|
|
* 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-25 20:15:05 +01:00
|
|
|
|
2013-02-04 23:38:59 +01:00
|
|
|
int group_initialize(FAR struct task_tcb_s *tcb)
|
2013-01-25 20:15:05 +01:00
|
|
|
{
|
2013-01-25 18:23:38 +01:00
|
|
|
FAR struct task_group_s *group;
|
2014-08-26 22:54:39 +02:00
|
|
|
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
|
2013-01-26 18:28:20 +01:00
|
|
|
irqstate_t flags;
|
|
|
|
#endif
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2013-02-04 23:38:59 +01:00
|
|
|
DEBUGASSERT(tcb && tcb->cmn.group);
|
|
|
|
group = tcb->cmn.group;
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2013-01-26 00:21:27 +01:00
|
|
|
#ifdef HAVE_GROUP_MEMBERS
|
2013-01-25 20:15:05 +01:00
|
|
|
/* Allocate space to hold GROUP_INITIAL_MEMBERS members of the group */
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2017-08-15 01:19:27 +02:00
|
|
|
group->tg_members = (FAR pid_t *)kmm_malloc(GROUP_INITIAL_MEMBERS * sizeof(pid_t));
|
2013-01-25 20:15:05 +01:00
|
|
|
if (!group->tg_members)
|
2013-01-25 18:23:38 +01:00
|
|
|
{
|
2014-09-01 01:04:02 +02:00
|
|
|
kmm_free(group);
|
2013-01-25 18:23:38 +01:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2013-02-04 23:38:59 +01:00
|
|
|
/* Assign the PID of this new task as a member of the group. */
|
2013-01-25 20:15:05 +01:00
|
|
|
|
2013-02-04 23:38:59 +01:00
|
|
|
group->tg_members[0] = tcb->cmn.pid;
|
2013-01-25 20:15:05 +01:00
|
|
|
|
|
|
|
/* Initialize the non-zero elements of group structure and assign it to
|
|
|
|
* the tcb.
|
|
|
|
*/
|
|
|
|
|
|
|
|
group->tg_mxmembers = GROUP_INITIAL_MEMBERS; /* Number of members in allocation */
|
2013-01-26 18:28:20 +01:00
|
|
|
|
2014-08-26 22:54:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
|
2013-01-26 18:28:20 +01:00
|
|
|
/* Add the initialized entry to the list of groups */
|
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2013-01-26 18:28:20 +01:00
|
|
|
group->flink = g_grouphead;
|
|
|
|
g_grouphead = group;
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2013-01-26 18:28:20 +01:00
|
|
|
|
2013-01-25 20:15:05 +01:00
|
|
|
#endif
|
2013-01-25 18:23:38 +01:00
|
|
|
|
2013-02-04 23:38:59 +01:00
|
|
|
/* Save the ID of the main task within the group of threads. This needed
|
|
|
|
* for things like SIGCHILD. It ID is also saved in the TCB of the main
|
|
|
|
* task but is also retained in the group which may persist after the main
|
|
|
|
* task has exited.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
|
|
|
|
group->tg_task = tcb->cmn.pid;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Mark that there is one member in the group, the main task */
|
|
|
|
|
|
|
|
group->tg_nmembers = 1;
|
2013-01-25 18:23:38 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|