2013-02-03 17:43:58 +01:00
|
|
|
/*****************************************************************************
|
2014-08-09 00:44:08 +02:00
|
|
|
* sched/task/task_getgroup.c
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2013-02-03 17:43:58 +01:00
|
|
|
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
2012-07-14 21:30:31 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-12-14 20:30:18 +01:00
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
2007-02-18 00:21:28 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2013-02-03 17:43:58 +01:00
|
|
|
*****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
/*****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2013-02-03 17:43:58 +01:00
|
|
|
*****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
#include <nuttx/config.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
#include <sched.h>
|
2007-02-18 00:21:28 +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"
|
2014-08-09 00:44:08 +02:00
|
|
|
#include "task/task.h"
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
#ifdef HAVE_TASK_GROUP
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
*****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Private Functions
|
2013-02-03 17:43:58 +01:00
|
|
|
*****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
/*****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Functions
|
2013-02-03 17:43:58 +01:00
|
|
|
*****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Name: task_getgroup
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2013-02-03 17:43:58 +01:00
|
|
|
* Given a task ID, return the group structure of this task.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Parameters:
|
2013-02-03 17:43:58 +01:00
|
|
|
* pid - The task ID to use in the lookup.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Return Value:
|
2013-02-03 17:43:58 +01:00
|
|
|
* On success, a pointer to the group task structure is returned. This
|
|
|
|
* function can fail only if there is no group that corresponds to the
|
|
|
|
* groupd ID.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2013-02-03 17:43:58 +01:00
|
|
|
* Called during when signally tasks in a safe context. No special
|
|
|
|
* precautions should be required here. However, extra care is taken when
|
|
|
|
* accessing the global g_grouphead list.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2013-02-03 17:43:58 +01:00
|
|
|
*****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
FAR struct task_group_s *task_getgroup(pid_t pid)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2013-02-04 19:46:28 +01:00
|
|
|
FAR struct tcb_s *tcb = sched_gettcb(pid);
|
2013-02-03 17:43:58 +01:00
|
|
|
if (tcb)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2013-02-03 17:43:58 +01:00
|
|
|
return tcb->group;
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
return NULL;
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
2007-02-27 22:17:21 +01:00
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
#endif /* HAVE_TASK_GROUP */
|