2007-07-01 01:05:44 +08:00
|
|
|
/****************************************************************************
|
2014-08-09 04:06:42 +08:00
|
|
|
* sched/group/group.h
|
2007-07-01 01:05:44 +08:00
|
|
|
*
|
2024-09-11 19:45:11 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2020-05-16 23:06:29 +08: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-07-01 01:05:44 +08:00
|
|
|
*
|
2020-05-16 23:06:29 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-07-01 01:05:44 +08:00
|
|
|
*
|
2020-05-16 23:06:29 +08: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-07-01 01:05:44 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-09 04:06:42 +08:00
|
|
|
#ifndef __SCHED_GROUP_GROUP_H
|
|
|
|
#define __SCHED_GROUP_GROUP_H
|
2013-01-26 07:21:27 +08:00
|
|
|
|
2007-07-01 01:05:44 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2009-12-15 02:39:29 +08:00
|
|
|
#include <sys/types.h>
|
2013-01-26 07:21:27 +08:00
|
|
|
#include <stdbool.h>
|
2007-07-01 01:05:44 +08:00
|
|
|
#include <sched.h>
|
2011-04-04 04:41:49 +08:00
|
|
|
|
|
|
|
#include <nuttx/kmalloc.h>
|
2019-08-03 00:01:30 +08:00
|
|
|
#include <nuttx/sched.h>
|
2011-04-04 04:41:49 +08:00
|
|
|
|
2007-07-01 01:05:44 +08:00
|
|
|
/****************************************************************************
|
2013-01-26 07:21:27 +08:00
|
|
|
* Public Type Definitions
|
2007-07-01 01:05:44 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
2013-02-06 23:43:28 +08:00
|
|
|
typedef int (*foreachchild_t)(pid_t pid, FAR void *arg);
|
|
|
|
|
2007-07-01 01:05:44 +08:00
|
|
|
/****************************************************************************
|
2013-01-27 01:28:20 +08:00
|
|
|
* Public Data
|
2007-07-01 01:05:44 +08:00
|
|
|
****************************************************************************/
|
2014-08-27 04:54:39 +08:00
|
|
|
|
2013-01-26 07:21:27 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
2014-08-09 06:44:08 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_CHILD_STATUS
|
2022-08-16 12:20:39 +08:00
|
|
|
void task_initialize(void);
|
|
|
|
#else
|
|
|
|
# define task_initialize()
|
2014-08-09 06:44:08 +08:00
|
|
|
#endif
|
|
|
|
|
2013-01-26 07:21:27 +08:00
|
|
|
/* Task group data structure management */
|
|
|
|
|
2024-03-04 09:19:27 +08:00
|
|
|
int group_initialize(FAR struct task_tcb_s *tcb, uint8_t ttype);
|
|
|
|
void group_postinitialize(FAR struct task_tcb_s *tcb);
|
2013-02-05 06:38:59 +08:00
|
|
|
#ifndef CONFIG_DISABLE_PTHREAD
|
2024-06-06 15:03:40 +08:00
|
|
|
void group_bind(FAR struct pthread_tcb_s *tcb);
|
|
|
|
void group_join(FAR struct pthread_tcb_s *tcb);
|
2013-02-05 06:38:59 +08:00
|
|
|
#endif
|
2013-02-05 02:46:28 +08:00
|
|
|
void group_leave(FAR struct tcb_s *tcb);
|
2023-01-26 20:45:13 +08:00
|
|
|
void group_drop(FAR struct task_group_s *group);
|
2015-12-23 01:48:17 +08:00
|
|
|
#if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT)
|
2020-05-16 23:06:29 +08:00
|
|
|
void group_add_waiter(FAR struct task_group_s *group);
|
|
|
|
void group_del_waiter(FAR struct task_group_s *group);
|
2015-12-23 01:48:17 +08:00
|
|
|
#endif
|
2013-01-27 01:28:20 +08:00
|
|
|
|
2014-08-27 04:54:39 +08:00
|
|
|
#ifdef HAVE_GROUP_MEMBERS
|
2013-02-06 23:43:28 +08:00
|
|
|
int group_foreachchild(FAR struct task_group_s *group,
|
|
|
|
foreachchild_t handler, FAR void *arg);
|
2020-06-03 19:33:56 +08:00
|
|
|
int group_kill_children(FAR struct tcb_s *tcb);
|
2018-08-31 00:27:18 +08:00
|
|
|
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
2020-05-16 23:06:29 +08:00
|
|
|
int group_suspend_children(FAR struct tcb_s *tcb);
|
2018-09-03 03:51:52 +08:00
|
|
|
int group_continue(FAR struct tcb_s *tcb);
|
2018-08-31 00:27:18 +08:00
|
|
|
#endif
|
2013-01-27 01:28:20 +08:00
|
|
|
#endif
|
|
|
|
|
2013-02-04 00:43:58 +08:00
|
|
|
/* Convenience functions */
|
|
|
|
|
|
|
|
FAR struct task_group_s *task_getgroup(pid_t pid);
|
|
|
|
|
|
|
|
/* Signaling group members */
|
|
|
|
|
2019-04-30 04:52:05 +08:00
|
|
|
int group_signal(FAR struct task_group_s *group, FAR siginfo_t *siginfo);
|
2013-01-26 07:21:27 +08: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 23:06:29 +08: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-27 01:28:20 +08:00
|
|
|
|
2013-01-27 06:25:21 +08:00
|
|
|
#endif /* CONFIG_SCHED_CHILD_STATUS */
|
|
|
|
#endif /* CONFIG_SCHED_HAVE_PARENT */
|
|
|
|
|
2013-01-27 07:49:02 +08:00
|
|
|
/* Group data resource configuration */
|
2013-01-27 05:01:19 +08:00
|
|
|
|
2023-10-15 14:27:39 +08:00
|
|
|
int group_setupidlefiles(void);
|
2023-11-13 20:59:42 +08:00
|
|
|
int group_setuptaskfiles(FAR struct task_tcb_s *tcb,
|
|
|
|
FAR const posix_spawn_file_actions_t *actions,
|
|
|
|
bool cloexec);
|
2013-01-27 05:01:19 +08:00
|
|
|
|
2014-08-09 04:06:42 +08:00
|
|
|
#endif /* __SCHED_GROUP_GROUP_H */
|