The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kern/task.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993-1988 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        task.h,v $
   29  * Revision 2.13  93/11/17  17:29:40  dbg
   30  *      Remove itk_lock in favor of task_lock.
   31  *      [93/07/12            dbg]
   32  * 
   33  *      Added separate task_ref_lock to simplify interactions between
   34  *      task locks and processor set locks.
   35  *      [93/06/10            dbg]
   36  * 
   37  *      Add scheduling policy for newly created threads; change priority
   38  *      to a policy-specific field.
   39  *      [93/05/10            dbg]
   40  * 
   41  *      Removed include of kern/processor.h.  We only need the type
   42  *      declaration from kern/kern_types.h.
   43  *      [93/04/09            dbg]
   44  * 
   45  *      Converted time_values to time_specs.
   46  *      [93/01/28            dbg]
   47  * 
   48  * Revision 2.12  93/08/10  15:12:22  mrt
   49  *      Conditionalized atm hooks.
   50  *      [93/07/30            cmaeda]
   51  *      Included hooks for network interface.
   52  *      [93/06/09  15:43:43  jcb]
   53  * 
   54  * Revision 2.11  93/01/24  13:20:05  danner
   55  *      Added sample_control to indicate that all the threads of the task are
   56  *      to have their pc's sampled periodically.
   57  *      [93/01/12            rvb]
   58  * 
   59  * Revision 2.10  93/01/21  12:22:26  danner
   60  *      Expanded to allow TASK_FAST_TAS_NRAS ras.
   61  *      [93/01/19  16:33:32  bershad]
   62  * 
   63  * Revision 2.9  93/01/19  09:01:02  danner
   64  *      Corrected argument types.
   65  *      [93/01/19            danner]
   66  * 
   67  * Revision 2.8  93/01/14  17:36:49  danner
   68  *      Moved actual declaration of struct task and task_t to
   69  *      kern/kern_types.h, to permit mutually recursive structure
   70  *      definitions.  Added ANSI function prototypes.
   71  *      [92/12/28            dbg]
   72  *      Swapped fields for better alignment.
   73  *      [92/12/01            af]
   74  * 
   75  * Revision 2.7  92/07/20  13:33:02  cmaeda
   76  *      Added fast tas addresses to task structure.
   77  *      [92/05/11  14:36:52  cmaeda]
   78  * 
   79  * Revision 2.6  91/11/15  14:11:16  rpd
   80  *      NORMA_TASK: added child_node field, which determines where child tasks
   81  *      are created for the given task. A value of -1 means local node.
   82  *      [91/09/23  09:19:35  jsb]
   83  * 
   84  * Revision 2.5  91/05/14  16:48:20  mrt
   85  *      Correcting copyright
   86  * 
   87  * Revision 2.4  91/02/05  17:30:06  mrt
   88  *      Changed to new Mach copyright
   89  *      [91/02/01  16:19:18  mrt]
   90  * 
   91  * Revision 2.3  90/06/02  14:56:48  rpd
   92  *      Removed kernel_vm_space, keep_wired.  They are no longer needed.
   93  *      [90/04/29            rpd]
   94  *      Converted to new IPC.
   95  *      [90/03/26  22:23:06  rpd]
   96  * 
   97  * Revision 2.2  89/09/08  11:26:47  dbg
   98  *      Add 'keep_wired' privilege field, to allow out-of-line data
   99  *      passed to task to remain wired.  Needed for default pager.
  100  *      Remove kernel_vm_space (not used).
  101  *      [89/07/17            dbg]
  102  * 
  103  * 19-Oct-88  David Golub (dbg) at Carnegie-Mellon University
  104  *      Removed all non-MACH data structures.
  105  *
  106  * Revision 2.6  88/09/25  22:16:41  rpd
  107  *      Changed port_cache fields/definitions to obj_cache.
  108  *      [88/09/24  18:13:13  rpd]
  109  * 
  110  * Revision 2.5  88/08/24  02:46:30  mwyoung
  111  *      Adjusted include file references.
  112  *      [88/08/17  02:24:13  mwyoung]
  113  * 
  114  * Revision 2.4  88/07/20  21:07:49  rpd
  115  * Added ipc_task_lock/ipc_task_unlock definitions.
  116  * Changes for port sets.
  117  * Add ipc_next_name field, used for assigning local port names.
  118  * 
  119  * Revision 2.3  88/07/17  18:56:33  mwyoung
  120  * .
  121  * 
  122  * Revision 2.2.2.1  88/06/28  20:02:03  mwyoung
  123  * Cleaned up.  Replaced task_t->kernel_only with
  124  * task_t->kernel_ipc_space, task_t->kernel_vm_space, and
  125  * task_t->ipc_privilege, to prevent overloading errors.
  126  * 
  127  * Remove current_task() declaration.
  128  * Eliminate paging_task.
  129  * 
  130  * Revision 2.2.1.2  88/06/26  00:45:49  rpd
  131  * Changes for port sets.
  132  * 
  133  * Revision 2.2.1.1  88/06/23  23:32:38  rpd
  134  * Add ipc_next_name field, used for assigning local port names.
  135  * 
  136  * 21-Jun-88  Michael Young (mwyoung) at Carnegie-Mellon University
  137  *      Cleaned up.  Replaced task_t->kernel_only with
  138  *      task_t->kernel_ipc_space, task_t->kernel_vm_space, and
  139  *      task_t->ipc_privilege, to prevent overloading errors.
  140  *
  141  * 19-Apr-88  Michael Young (mwyoung) at Carnegie-Mellon University
  142  *      Remove current_task() declaration.
  143  *      Eliminate paging_task.
  144  *
  145  * 18-Jan-88  David Golub (dbg) at Carnegie-Mellon University
  146  *      Removed task_data (now is per_thread).  Added
  147  *      task_bootstrap_port.  Added new routine declarations.
  148  *      Removed wake_active (unused).  Added fields to accumulate
  149  *      user and system time for terminated threads.
  150  *
  151  *  19-Feb-88 Douglas Orr (dorr) at Carnegie-Mellon University
  152  *      Change emulation bit mask into vector of routine  addrs
  153  *
  154  *  27-Jan-87 Douglas Orr (dorr) at Carnegie-Mellon University
  155  *      Add support for user space syscall emulation (bit mask
  156  *      of enabled user space syscalls and user space emulation
  157  *      routine).
  158  *
  159  *  3-Dec-87  Michael Young (mwyoung) at Carnegie-Mellon University
  160  *      Change port cache account for per-task port names.
  161  *      Should move IPC stuff to a separate file :-).
  162  *      Add reply port for use by kernel-internal tasks.
  163  *
  164  *  2-Dec-87  David Black (dlb) at Carnegie-Mellon University
  165  *      Added active field.
  166  *
  167  * 18-Nov-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  168  *      Eliminate conditionals, flush history.
  169  */
  170 /*
  171  *      File:   task.h
  172  *      Author: Avadis Tevanian, Jr.
  173  *
  174  *      This file contains the structure definitions for tasks.
  175  *
  176  */
  177 
  178 #ifndef _KERN_TASK_H_
  179 #define _KERN_TASK_H_
  180 
  181 #include <fast_tas.h>
  182 #include <mach_pcsample.h>
  183 #include <net_atm.h>
  184 #include <norma_task.h>
  185 
  186 #include <mach/boolean.h>
  187 #include <mach/port.h>
  188 #include <mach/time_spec.h>
  189 #include <mach/mach_param.h>
  190 #include <mach/task_info.h>
  191 
  192 #include <kern/kern_types.h>
  193 #include <kern/lock.h>
  194 #include <kern/queue.h>
  195 #include <kern/sched_policy.h>
  196 #include <kern/syscall_emulation.h>
  197 
  198 #include <vm/vm_map.h>
  199 
  200 #if     MACH_PCSAMPLE
  201 #include <kern/pc_sample.h>
  202 #endif
  203 
  204 #if     NET_ATM
  205 typedef struct nw_ep_owned {
  206   unsigned int ep;
  207   struct nw_ep_owned *next;
  208 } nw_ep_owned_s, *nw_ep_owned_t;
  209 #endif
  210 
  211 struct task {
  212         /* Synchronization/destruction information */
  213         decl_simple_lock_data(,lock)    /* Task's lock */
  214         decl_simple_lock_data(,ref_lock) /* lock for reference count */
  215         int             ref_count;      /* Number of references to me */
  216         boolean_t       active;         /* Task has not been terminated */
  217 
  218         /* Miscellaneous */
  219         vm_map_t        map;            /* Address space description */
  220         queue_chain_t   pset_tasks;     /* list of tasks assigned to pset */
  221         int             suspend_count;  /* Internal scheduling only */
  222 
  223         /* Thread information */
  224         queue_head_t    thread_list;    /* list of threads */
  225         int             thread_count;   /* number of threads */
  226         processor_set_t processor_set;  /* processor set for new threads */
  227         unsigned int
  228         /* boolean_t */ may_assign:1,   /* can assigned pset be changed? */
  229         /* boolean_t */ assign_wait:1;  /* waiting for may_assign */
  230 
  231         /* User-visible scheduling information */
  232         int             user_stop_count;
  233                                         /* outstanding stops */
  234         sched_policy_t  sched_policy;   /* default scheduling policy and */
  235         sched_param_data_t
  236                         sched_data;     /* scheduling data for new threads */
  237         natural_t       sched_data_count;
  238 
  239         /* Statistics */
  240         time_spec_t     total_user_time;
  241                                         /* total user time for dead threads */
  242         time_spec_t     total_system_time;
  243                                         /* total system time for dead threads */
  244 
  245         /* IPC structures */
  246         struct ipc_port *itk_self;      /* not a right, doesn't hold ref */
  247         struct ipc_port *itk_sself;     /* a send right */
  248         struct ipc_port *itk_exception; /* a send right */
  249         struct ipc_port *itk_bootstrap; /* a send right */
  250         struct ipc_port *itk_registered[TASK_PORT_REGISTER_MAX];
  251                                         /* all send rights */
  252 
  253         struct ipc_space *itk_space;    /* port space for task */
  254 
  255         /* User space system call emulation support */
  256         struct  eml_dispatch    *eml_dispatch;
  257 
  258 #if     MACH_PCSAMPLE
  259         sample_control_t pc_sample;
  260 #endif
  261 
  262 #if     NORMA_TASK
  263         long            child_node;     /* if != -1, node for new children */
  264 #endif  /* NORMA_TASK */
  265 
  266 #if     FAST_TAS
  267 #define TASK_FAST_TAS_NRAS      8       
  268         vm_offset_t     fast_tas_base[TASK_FAST_TAS_NRAS];
  269         vm_offset_t     fast_tas_end[TASK_FAST_TAS_NRAS];
  270 #endif  /* FAST_TAS */
  271 
  272 #if     NET_ATM
  273         nw_ep_owned_t   nw_ep_owned;
  274 #endif  /* NET_ATM */
  275 };
  276 
  277 #define task_lock(task)         simple_lock(&(task)->lock)
  278 #define task_unlock(task)       simple_unlock(&(task)->lock)
  279 #define task_ref_lock(task)     simple_lock(&(task)->ref_lock)
  280 #define task_ref_unlock(task)   simple_unlock(&(task)->ref_lock)
  281 
  282 /*
  283  *      Exported routines/macros
  284  */
  285 
  286 extern kern_return_t    task_create(
  287                 task_t          parent_task,
  288                 boolean_t       inherit_memory,
  289                 task_t          *child_task);
  290 
  291 extern kern_return_t    task_terminate(
  292                 task_t          task);
  293 
  294 extern kern_return_t    task_suspend(
  295                 task_t          task);
  296 
  297 extern kern_return_t    task_resume(
  298                 task_t          task);
  299 
  300 extern kern_return_t    task_threads(
  301                 task_t          task,
  302                 thread_array_t  *thread_list,
  303                 natural_t       *count);
  304 
  305 extern kern_return_t    task_info(
  306                 task_t          task,
  307                 int             flavor,
  308                 task_info_t     task_info_out,
  309                 natural_t       *task_info_count);
  310 
  311 extern kern_return_t    task_get_special_port(
  312                 task_t          task,
  313                 int             which,
  314                 struct ipc_port **portp);
  315 
  316 extern kern_return_t    task_set_special_port(
  317                 task_t          task,
  318                 int             which,
  319                 struct ipc_port *port);
  320 
  321 extern kern_return_t    task_assign(
  322                 task_t          task,
  323                 processor_set_t new_pset,
  324                 boolean_t       assign_threads);
  325 
  326 extern kern_return_t    task_assign_default(
  327                 task_t          task,
  328                 boolean_t       assign_threads);
  329 
  330 extern kern_return_t    task_set_default_policy(
  331                 task_t          task,
  332                 processor_set_t pset,
  333                 int             policy,
  334                 policy_param_t  param,
  335                 natural_t       count,
  336                 boolean_t       assign_threads);
  337 
  338 /*
  339  *      Internal only routines
  340  */
  341 
  342 extern void             task_init(void);
  343 extern void             task_reference(task_t);
  344 extern void             task_deallocate(task_t);
  345 extern kern_return_t    task_hold(task_t);
  346 extern kern_return_t    task_dowait(task_t, boolean_t);
  347 extern kern_return_t    task_release(task_t);
  348 
  349 extern task_t           kernel_task_create(task_t, vm_size_t);
  350 
  351 extern void             consider_task_collect(void);    /* garbage collection */
  352 
  353 extern task_t   kernel_task;
  354 
  355 #endif  /* _KERN_TASK_H_ */

Cache object: f5d5945a2d2efc3b9c0837c32c60b1f0


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.