54 #ifndef __INCLUDE_TINYARA_SCHED_H 55 #define __INCLUDE_TINYARA_SCHED_H 61 #include <tinyara/config.h> 63 #include <sys/types.h> 72 #include <tinyara/irq.h> 73 #include <tinyara/mm/shm.h> 74 #include <tinyara/fs/fs.h> 75 #include <tinyara/net/net.h> 77 #include <arch/arch.h> 85 #undef HAVE_TASK_GROUP 86 #undef HAVE_GROUP_MEMBERS 92 #if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS) 93 #define HAVE_TASK_GROUP 1 94 #define HAVE_GROUP_MEMBERS 1 103 #if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT) 104 #define HAVE_TASK_GROUP 1 105 #elif !defined(CONFIG_DISABLE_ENVIRON) 106 #define HAVE_TASK_GROUP 1 107 #elif !defined(CONFIG_DISABLE_SIGNALS) 108 #define HAVE_TASK_GROUP 1 109 #elif defined(CONFIG_SCHED_ATEXIT) 110 #define HAVE_TASK_GROUP 1 111 #elif defined(CONFIG_SCHED_ONEXIT) 112 #define HAVE_TASK_GROUP 1 113 #elif defined(CONFIG_SCHED_WAITPID) 114 #define HAVE_TASK_GROUP 1 115 #elif CONFIG_NFILE_DESCRIPTORS > 0 116 #define HAVE_TASK_GROUP 1 117 #elif CONFIG_NFILE_STREAMS > 0 118 #define HAVE_TASK_GROUP 1 119 #elif CONFIG_NSOCKET_DESCRIPTORS > 0 120 #define HAVE_TASK_GROUP 1 121 #elif !defined(CONFIG_DISABLE_MQUEUE) 122 #define HAVE_TASK_GROUP 1 123 #elif defined(CONFIG_ARCH_ADDRENV) 124 #define HAVE_TASK_GROUP 1 125 #elif defined(CONFIG_MM_SHM) 126 #define HAVE_TASK_GROUP 1 132 #ifdef CONFIG_DISABLE_PTHREAD 133 #undef HAVE_GROUP_MEMBERS 139 #define NULL_TASK_PROCESS_ID (pid_t)0 140 #define INVALID_PROCESS_ID (pid_t)-1 144 #define MAX_LOCK_COUNT 127 148 #define TCB_FLAG_TTYPE_SHIFT (0) 149 #define TCB_FLAG_TTYPE_MASK (3 << TCB_FLAG_TTYPE_SHIFT) 150 #define TCB_FLAG_TTYPE_TASK (0 << TCB_FLAG_TTYPE_SHIFT) 151 #define TCB_FLAG_TTYPE_PTHREAD (1 << TCB_FLAG_TTYPE_SHIFT) 152 #define TCB_FLAG_TTYPE_KERNEL (2 << TCB_FLAG_TTYPE_SHIFT) 153 #define TCB_FLAG_NONCANCELABLE (1 << 2) 154 #define TCB_FLAG_CANCEL_PENDING (1 << 3) 155 #define TCB_FLAG_ROUND_ROBIN (1 << 4) 156 #define TCB_FLAG_EXIT_PROCESSING (1 << 5) 160 #define GROUP_FLAG_NOCLDWAIT (1 << 0) 161 #define GROUP_FLAG_ADDRENV (1 << 1) 162 #define GROUP_FLAG_PRIVILEGED (1 << 2) 166 #define CHILD_FLAG_TTYPE_SHIFT (0) 167 #define CHILD_FLAG_TTYPE_MASK (3 << CHILD_FLAG_TTYPE_SHIFT) 168 #define CHILD_FLAG_TTYPE_TASK (0 << CHILD_FLAG_TTYPE_SHIFT) 169 #define CHILD_FLAG_TTYPE_PTHREAD (1 << CHILD_FLAG_TTYPE_SHIFT) 170 #define CHILD_FLAG_TTYPE_KERNEL (2 << CHILD_FLAG_TTYPE_SHIFT) 171 #define CHILD_FLAG_EXITED (1 << 0) 195 #ifndef CONFIG_DISABLE_SIGNALS 198 #ifndef CONFIG_DISABLE_MQUEUE 203 TSTATE_WAIT_PAGEFILL,
211 #define FIRST_READY_TO_RUN_STATE TSTATE_TASK_READYTORUN 212 #define LAST_READY_TO_RUN_STATE TSTATE_TASK_RUNNING 213 #define FIRST_BLOCKED_STATE TSTATE_TASK_INACTIVE 214 #define LAST_BLOCKED_STATE (NUM_TASK_STATES-1) 231 #ifdef CONFIG_SCHED_STARTHOOK 239 #ifdef CONFIG_SCHED_ATEXIT 243 #ifdef CONFIG_SCHED_ONEXIT 252 #ifdef CONFIG_SCHED_CHILD_STATUS 310 #ifdef HAVE_TASK_GROUP 312 #ifndef CONFIG_DISABLE_PTHREAD 318 #if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV) 322 #ifdef HAVE_GROUP_MEMBERS 325 #if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT) 333 #ifdef HAVE_GROUP_MEMBERS 338 #if defined(CONFIG_SCHED_ATEXIT) && !defined(CONFIG_SCHED_ONEXIT) 341 #if defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1 348 #ifdef CONFIG_SCHED_ONEXIT 351 #if defined(CONFIG_SCHED_ONEXIT_MAX) && CONFIG_SCHED_ONEXIT_MAX > 1 360 #if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS) 366 #if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT) 374 #ifndef CONFIG_DISABLE_PTHREAD 383 #ifndef CONFIG_DISABLE_SIGNALS 389 #ifndef CONFIG_DISABLE_ENVIRON 402 #if CONFIG_NFILE_DESCRIPTORS > 0 405 struct filelist tg_filelist;
408 #if CONFIG_NFILE_STREAMS > 0 415 #if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ 416 defined(CONFIG_MM_KERNEL_HEAP) 417 FAR
struct streamlist *tg_streamlist;
419 struct streamlist tg_streamlist;
423 #if CONFIG_NSOCKET_DESCRIPTORS > 0 426 struct socketlist tg_socketlist;
429 #ifndef CONFIG_DISABLE_MQUEUE 435 #ifdef CONFIG_ARCH_ADDRENV 438 group_addrenv_t tg_addrenv;
444 struct group_shm_s tg_shm;
464 #ifdef HAVE_TASK_GROUP 472 #ifdef CONFIG_SCHED_HAVE_PARENT 473 #ifndef HAVE_GROUP_MEMBERS 475 #ifndef CONFIG_SCHED_CHILD_STATUS 485 #ifdef CONFIG_PRIORITY_INHERITANCE 486 #if CONFIG_SEM_NNESTPRIO > 0 487 uint8_t npend_reprio;
488 uint8_t pend_reprios[CONFIG_SEM_NNESTPRIO];
497 #if CONFIG_RR_INTERVAL > 0 524 #ifndef CONFIG_DISABLE_SIGNALS 535 #ifndef CONFIG_DISABLE_MQUEUE 546 struct xcptcontext xcp;
548 #if CONFIG_TASK_NAME_SIZE > 0 549 char name[CONFIG_TASK_NAME_SIZE + 1];
552 #ifdef CONFIG_DEBUG_MM_HEAPINFO 575 #ifdef CONFIG_SCHED_STARTHOOK 588 #ifndef CONFIG_DISABLE_PTHREAD 609 #if CONFIG_NPTHREAD_KEYS > 0 610 FAR
void *pthread_data[CONFIG_NPTHREAD_KEYS];
612 #if defined(CONFIG_BUILD_PROTECTED) 630 #if defined(__cplusplus) 631 #define EXTERN extern "C" 634 #define EXTERN extern 687 #if CONFIG_NFILE_DESCRIPTORS > 0 692 FAR
struct filelist *sched_getfiles(
void);
696 #if CONFIG_NFILE_STREAMS > 0 703 FAR
struct streamlist *sched_getstreams(
void);
707 #if CONFIG_NSOCKET_DESCRIPTORS > 0 708 FAR
struct socketlist *sched_getsockets(
void);
730 #ifdef CONFIG_SCHED_STARTHOOK 772 pid_t task_vforkstart(FAR
struct task_tcb_s *child);
776 void task_vforkabort(FAR
struct task_tcb_s *child,
int errcode);
781 #if defined(__cplusplus)
FAR struct tcb_s * sched_gettcb(pid_t pid)
Give a task ID, look up the corresponding TCB.
This structure describes a reference counted D-Space region. This must be a separately allocated "bre...
sq_queue_t sigpendactionq
CODE void(* start_t)(void)
void(* sched_foreach_t)(FAR struct tcb_s *tcb, FAR void *arg)
FAR struct wdog_s * waitdog
FAR struct child_status_s * tg_children
FAR void * pthread_addr_t
This structure is used to maintin information about child tasks. pthreads work differently, they have join information. This is only for child tasks.
structure for header queue
CODE void(* starthook_t)(FAR void *arg)
FAR struct join_s * tg_jointail
Structure for using to pass parameters to/from signal handlers.
This is the common part of the task control block (TCB). The TCB is the heart of the TinyAra task-con...
FAR struct join_s * tg_joinhead
FAR struct tcb_s * sched_self(void)
returns the TCB of the currently running task (i.e., the caller)
Structure for Task Group Information.
CODE void(* atexitfunc_t)(void)
tstate_e
This is the type of the task_state field of the TCB. NOTE: the order and content of this enumeration ...
onexitfunc_t tg_onexitfunc
FAR void * stack_alloc_ptr
FAR struct task_group_s * group
void sched_foreach(sched_foreach_t handler, FAR void *arg)
enumerate over each task and provide the TCB of each task or thread to a callback function...
struct task_group_s * flink
FAR struct mqueue_inode_s * msgwaitq
This is the particular form of the task control block (TCB) structure used by pthreads. There are two TCB forms: one for pthreads and one for tasks. Both share the common TCB fields (which must appear at the top of the structure) plus additional fields unique to tasks and threads. Having separate structures for tasks and pthreads adds some complexity, but saves memory in that it prevents pthreads from being burdened with the overhead required for tasks (and vice versa).
Structure of generic semaphore.
pthread_addr_t(* pthread_startroutine_t)(pthread_addr_t)
This is the entry point into the main thread of the task or into a created pthread within the task...
FAR struct child_status_s * flink
FAR struct dspace_s * dspace
This is the particular form of the task control block (TCB) structure used by tasks (and kernel threa...
Structure of pthread region configuration.
CODE void(* onexitfunc_t)(int exitcode, FAR void *arg)
pthread_startroutine_t pthread