2007-06-30 19:05:44 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 22:06:42 +02:00
|
|
|
* sched/group/group.h
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
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
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
2020-05-16 17:06:29 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
2020-05-16 17:06:29 +02:00
|
|
|
* 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.
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-08 22:06:42 +02:00
|
|
|
#ifndef __SCHED_GROUP_GROUP_H
|
|
|
|
#define __SCHED_GROUP_GROUP_H
|
2013-01-26 00:21:27 +01:00
|
|
|
|
2007-06-30 19:05:44 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2009-12-14 19:39:29 +01:00
|
|
|
#include <sys/types.h>
|
2013-01-26 00:21:27 +01:00
|
|
|
#include <stdbool.h>
|
2007-06-30 19:05:44 +02:00
|
|
|
#include <sched.h>
|
2011-04-03 22:41:49 +02:00
|
|
|
|
|
|
|
#include <nuttx/kmalloc.h>
|
2019-08-02 18:01:30 +02:00
|
|
|
#include <nuttx/sched.h>
|
2011-04-03 22:41:49 +02:00
|
|
|
|
2007-06-30 19:05:44 +02:00
|
|
|
/****************************************************************************
|
2013-01-26 00:21:27 +01:00
|
|
|
* Public Type Definitions
|
2007-06-30 19:05:44 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2013-02-06 16:43:28 +01:00
|
|
|
typedef int (*foreachchild_t)(pid_t pid, FAR void *arg);
|
|
|
|
|
2007-06-30 19:05:44 +02:00
|
|
|
/****************************************************************************
|
2013-01-26 18:28:20 +01:00
|
|
|
* Public Data
|
2007-06-30 19:05:44 +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 */
|
|
|
|
|
|
|
|
extern FAR struct task_group_s *g_grouphead;
|
|
|
|
#endif
|
|
|
|
|
2014-08-26 22:54:39 +02:00
|
|
|
#ifdef CONFIG_ARCH_ADDRENV
|
2022-05-06 11:58:38 +02:00
|
|
|
/* This variable holds the current task group. This pointer is NULL
|
|
|
|
* if the current task is a kernel thread that has no address environment
|
|
|
|
* (other than the kernel context).
|
2014-08-26 22:54:39 +02:00
|
|
|
*
|
|
|
|
* This must only be accessed with interrupts disabled.
|
|
|
|
*/
|
|
|
|
|
2022-05-06 11:58:38 +02:00
|
|
|
extern FAR struct task_group_s *g_group_current[CONFIG_SMP_NCPUS];
|
2014-08-26 22:54:39 +02:00
|
|
|
#endif
|
|
|
|
|
2013-01-26 00:21:27 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
2014-08-09 00:44:08 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_CHILD_STATUS
|
2022-08-16 06:20:39 +02:00
|
|
|
void task_initialize(void);
|
|
|
|
#else
|
|
|
|
# define task_initialize()
|
2014-08-09 00:44:08 +02:00
|
|
|
#endif
|
|
|
|
|
2013-01-26 00:21:27 +01:00
|
|
|
/* Task group data structure management */
|
|
|
|
|
2014-09-03 22:58:24 +02:00
|
|
|
int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype);
|
2022-03-01 19:24:05 +01:00
|
|
|
void group_initialize(FAR struct task_tcb_s *tcb);
|
2013-02-04 23:38:59 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PTHREAD
|
|
|
|
int group_bind(FAR struct pthread_tcb_s *tcb);
|
|
|
|
int group_join(FAR struct pthread_tcb_s *tcb);
|
|
|
|
#endif
|
2013-02-04 19:46:28 +01:00
|
|
|
void group_leave(FAR struct tcb_s *tcb);
|
2023-01-26 13:45:13 +01:00
|
|
|
void group_drop(FAR struct task_group_s *group);
|
2015-12-22 18:48:17 +01:00
|
|
|
#if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT)
|
2020-05-16 17:06:29 +02:00
|
|
|
void group_add_waiter(FAR struct task_group_s *group);
|
|
|
|
void group_del_waiter(FAR struct task_group_s *group);
|
2015-12-22 18:48:17 +01:00
|
|
|
#endif
|
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)
|
2021-03-03 18:11:40 +01:00
|
|
|
FAR struct task_group_s *group_findbypid(pid_t pid);
|
2014-08-26 22:54:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_GROUP_MEMBERS
|
2013-02-06 16:43:28 +01:00
|
|
|
int group_foreachchild(FAR struct task_group_s *group,
|
|
|
|
foreachchild_t handler, FAR void *arg);
|
2020-06-03 13:33:56 +02:00
|
|
|
int group_kill_children(FAR struct tcb_s *tcb);
|
2018-08-30 18:27:18 +02:00
|
|
|
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
2020-05-16 17:06:29 +02:00
|
|
|
int group_suspend_children(FAR struct tcb_s *tcb);
|
2018-09-02 21:51:52 +02:00
|
|
|
int group_continue(FAR struct tcb_s *tcb);
|
2018-08-30 18:27:18 +02:00
|
|
|
#endif
|
2013-01-26 18:28:20 +01:00
|
|
|
#endif
|
|
|
|
|
2014-08-26 22:54:39 +02:00
|
|
|
#ifdef CONFIG_ARCH_ADDRENV
|
|
|
|
/* Group address environment management */
|
|
|
|
|
|
|
|
int group_addrenv(FAR struct tcb_s *tcb);
|
|
|
|
#endif
|
|
|
|
|
2013-02-03 17:43:58 +01:00
|
|
|
/* Convenience functions */
|
|
|
|
|
|
|
|
FAR struct task_group_s *task_getgroup(pid_t pid);
|
|
|
|
|
|
|
|
/* Signaling group members */
|
|
|
|
|
2019-04-29 22:52:05 +02:00
|
|
|
int group_signal(FAR struct task_group_s *group, FAR siginfo_t *siginfo);
|
2013-01-26 00:21:27 +01:00
|
|
|
|
|
|
|
/* Parent/child data management */
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_HAVE_PARENT
|
|
|
|
int task_reparent(pid_t ppid, pid_t chpid);
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_CHILD_STATUS
|
2020-05-16 17:06:29 +02:00
|
|
|
FAR struct child_status_s *group_alloc_child(void);
|
|
|
|
void group_free_child(FAR struct child_status_s *status);
|
|
|
|
void group_add_child(FAR struct task_group_s *group,
|
|
|
|
FAR struct child_status_s *child);
|
|
|
|
FAR struct child_status_s *group_exit_child(FAR struct task_group_s *group);
|
|
|
|
FAR struct child_status_s *group_find_child(FAR struct task_group_s *group,
|
|
|
|
pid_t pid);
|
|
|
|
FAR struct child_status_s *group_remove_child(FAR struct task_group_s *group,
|
|
|
|
pid_t pid);
|
|
|
|
void group_remove_children(FAR struct task_group_s *group);
|
2013-01-26 18:28:20 +01:00
|
|
|
|
2013-01-26 23:25:21 +01:00
|
|
|
#endif /* CONFIG_SCHED_CHILD_STATUS */
|
|
|
|
#endif /* CONFIG_SCHED_HAVE_PARENT */
|
|
|
|
|
2013-01-27 00:49:02 +01:00
|
|
|
/* Group data resource configuration */
|
2013-01-26 22:01:19 +01:00
|
|
|
|
2013-02-04 22:24:00 +01:00
|
|
|
int group_setupidlefiles(FAR struct task_tcb_s *tcb);
|
|
|
|
int group_setuptaskfiles(FAR struct task_tcb_s *tcb);
|
2020-08-13 12:17:29 +02:00
|
|
|
#ifdef CONFIG_FILE_STREAM
|
2013-02-04 22:24:00 +01:00
|
|
|
int group_setupstreams(FAR struct task_tcb_s *tcb);
|
2013-01-27 00:49:02 +01:00
|
|
|
#endif
|
2013-01-26 22:01:19 +01:00
|
|
|
|
2014-08-08 22:06:42 +02:00
|
|
|
#endif /* __SCHED_GROUP_GROUP_H */
|