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/sys/lwp.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 /*      $NetBSD: lwp.h,v 1.46 2006/10/24 10:05:45 hannken Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Nathan J. Williams.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 #ifndef _SYS_LWP_H_
   40 #define _SYS_LWP_H_
   41 
   42 
   43 #if defined(_KERNEL)
   44 #include <machine/cpu.h>                /* curcpu() and cpu_info */
   45 #endif
   46 #include <machine/proc.h>               /* Machine-dependent proc substruct. */
   47 #include <sys/queue.h>
   48 #include <sys/callout.h>
   49 #include <sys/specificdata.h>
   50 
   51 struct  lwp {
   52         struct  lwp *l_forw;            /* Doubly-linked run/sleep queue. */
   53         struct  lwp *l_back;
   54         LIST_ENTRY(lwp) l_list;         /* Entry on list of all LWPs. */
   55 
   56         struct proc *l_proc;    /* Process with which we are associated. */
   57 
   58         LIST_ENTRY(lwp) l_sibling;      /* Entry on process's list of LWPs. */
   59 
   60         struct cpu_info * volatile l_cpu; /* CPU we're running on if
   61                                                SONPROC */
   62         specificdata_reference
   63                 l_specdataref;  /* subsystem lwp-specific data */
   64 
   65         int     l_flag;
   66         int     l_stat;
   67         lwpid_t l_lid;          /* LWP identifier; local to process. */
   68 
   69 #define l_startzero l_cred
   70         struct kauth_cred *l_cred;      /* Cached credentials */
   71         u_short l_acflag;       /* Accounting flags */
   72         u_int   l_swtime;       /* Time swapped in or out. */
   73         u_int   l_slptime;      /* Time since last blocked. */
   74 
   75         volatile const void *l_wchan;   /* Sleep address. */
   76         struct callout l_tsleep_ch;     /* callout for tsleep */
   77         const char *l_wmesg;    /* Reason for sleep. */
   78         int     l_holdcnt;      /* If non-zero, don't swap. */
   79         void    *l_ctxlink;     /* uc_link {get,set}context */
   80         int     l_dupfd;        /* Sideways return value from cloning devices XXX */
   81         struct sadata_vp *l_savp; /* SA "virtual processor" */
   82 
   83         int     l_locks;        /* DEBUG: lockmgr count of held locks */
   84         void    *l_private;     /* svr4-style lwp-private data */
   85 
   86 #define l_endzero l_priority
   87 
   88 #define l_startcopy l_priority
   89 
   90         u_char  l_priority;     /* Process priority. */
   91         u_char  l_usrpri;       /* User-priority based on p_cpu and p_nice. */
   92 
   93 #define l_endcopy l_emuldata
   94 
   95         void    *l_emuldata;    /* kernel lwp-private data */
   96 
   97         struct  user *l_addr;   /* Kernel virtual addr of u-area (PROC ONLY). */
   98         struct  mdlwp l_md;     /* Any machine-dependent fields. */
   99 };
  100 
  101 #if !defined(USER_TO_UAREA)
  102 #if !defined(UAREA_USER_OFFSET)
  103 #define UAREA_USER_OFFSET       0
  104 #endif /* !defined(UAREA_USER_OFFSET) */
  105 #define USER_TO_UAREA(user)     ((vaddr_t)(user) - UAREA_USER_OFFSET)
  106 #define UAREA_TO_USER(uarea)    ((struct user *)((uarea) + UAREA_USER_OFFSET))
  107 #endif /* !defined(UAREA_TO_USER) */
  108 
  109 LIST_HEAD(lwplist, lwp);                /* a list of LWPs */
  110 
  111 #ifdef _KERNEL
  112 extern struct lwplist alllwp;           /* List of all LWPs. */
  113 
  114 extern struct pool lwp_uc_pool;         /* memory pool for LWP startup args */
  115 
  116 extern struct lwp lwp0;                 /* LWP for proc0 */
  117 #endif
  118 
  119 /* These flags are kept in l_flag. [*] is shared with p_flag */
  120 #define L_INMEM         0x00000004 /* [*] Loaded into memory. */
  121 #define L_SELECT        0x00000040 /* [*] Selecting; wakeup/waiting danger. */
  122 #define L_SINTR         0x00000080 /* [*] Sleep is interruptible. */
  123 #define L_SA            0x00000400 /* [*] Scheduler activations LWP */
  124 #define L_SA_UPCALL     0x00200000 /* SA upcall is pending */
  125 #define L_SA_BLOCKING   0x00400000 /* Blocking in tsleep() */
  126 #define L_DETACHED      0x00800000 /* Won't be waited for. */
  127 #define L_CANCELLED     0x02000000 /* tsleep should not sleep */
  128 #define L_SA_PAGEFAULT  0x04000000 /* SA LWP in pagefault handler */
  129 #define L_TIMEOUT       0x08000000 /* Timing out during sleep. */
  130 #define L_SA_YIELD      0x10000000 /* LWP on VP is yielding */
  131 #define L_SA_IDLE       0x20000000 /* VP is idle */
  132 #define L_COWINPROGRESS 0x40000000 /* UFS: doing copy on write */
  133 #define L_SA_SWITCHING  0x80000000 /* SA LWP in context switch */
  134 
  135 /*
  136  * Status values.
  137  *
  138  * A note about SRUN and SONPROC: SRUN indicates that a process is
  139  * runnable but *not* yet running, i.e. is on a run queue.  SONPROC
  140  * indicates that the process is actually executing on a CPU, i.e.
  141  * it is no longer on a run queue.
  142  */
  143 #define LSIDL   1               /* Process being created by fork. */
  144 #define LSRUN   2               /* Currently runnable. */
  145 #define LSSLEEP 3               /* Sleeping on an address. */
  146 #define LSSTOP  4               /* Process debugging or suspension. */
  147 #define LSZOMB  5               /* Awaiting collection by parent. */
  148 #define LSDEAD  6               /* Process is almost a zombie. */
  149 #define LSONPROC        7       /* Process is currently on a CPU. */
  150 #define LSSUSPENDED     8       /* Not running, not signalable. */
  151 
  152 #ifdef _KERNEL
  153 #define PHOLD(l)                                                        \
  154 do {                                                                    \
  155         if ((l)->l_holdcnt++ == 0 && ((l)->l_flag & L_INMEM) == 0)      \
  156                 uvm_swapin(l);                                          \
  157 } while (/* CONSTCOND */ 0)
  158 #define PRELE(l)        (--(l)->l_holdcnt)
  159 
  160 #define LWP_CACHE_CREDS(l, p)                                           \
  161 do {                                                                    \
  162         if ((l)->l_cred != (p)->p_cred)                                 \
  163                 lwp_update_creds(l);                                    \
  164 } while (/* CONSTCOND */ 0)
  165 
  166 void    preempt (int);
  167 int     mi_switch (struct lwp *, struct lwp *);
  168 #ifndef remrunqueue
  169 void    remrunqueue (struct lwp *);
  170 #endif
  171 void    resetpriority (struct lwp *);
  172 void    setrunnable (struct lwp *);
  173 #ifndef setrunqueue
  174 void    setrunqueue (struct lwp *);
  175 #endif
  176 #ifndef nextrunqueue
  177 struct lwp *nextrunqueue(void);
  178 #endif
  179 void    unsleep (struct lwp *);
  180 #ifndef cpu_switch
  181 int     cpu_switch (struct lwp *, struct lwp *);
  182 #endif
  183 #ifndef cpu_switchto
  184 void    cpu_switchto (struct lwp *, struct lwp *);
  185 #endif
  186 
  187 int newlwp(struct lwp *, struct proc *, vaddr_t, int /* XXX boolean_t */, int,
  188     void *, size_t, void (*)(void *), void *, struct lwp **);
  189 
  190 /* Flags for _lwp_wait1 */
  191 #define LWPWAIT_EXITCONTROL     0x00000001
  192 void    lwpinit(void);
  193 int     lwp_wait1(struct lwp *, lwpid_t, lwpid_t *, int);
  194 void    lwp_continue(struct lwp *);
  195 void    cpu_setfunc(struct lwp *, void (*)(void *), void *);
  196 void    startlwp(void *);
  197 void    upcallret(struct lwp *);
  198 void    lwp_exit (struct lwp *);
  199 void    lwp_exit2 (struct lwp *);
  200 struct lwp *proc_representative_lwp(struct proc *);
  201 __inline int lwp_suspend(struct lwp *, struct lwp *);
  202 int     lwp_create1(struct lwp *, const void *, size_t, u_long, lwpid_t *);
  203 void    lwp_update_creds(struct lwp *);
  204 
  205 int     lwp_specific_key_create(specificdata_key_t *, specificdata_dtor_t);
  206 void    lwp_specific_key_delete(specificdata_key_t);
  207 void    lwp_initspecific(struct lwp *);
  208 void    lwp_finispecific(struct lwp *);
  209 void *  lwp_getspecific(specificdata_key_t);
  210 #if defined(_LWP_API_PRIVATE)
  211 void *  _lwp_getspecific_by_lwp(struct lwp *, specificdata_key_t);
  212 #endif
  213 void    lwp_setspecific(specificdata_key_t, void *);
  214 #endif  /* _KERNEL */
  215 
  216 /* Flags for _lwp_create(), as per Solaris. */
  217 
  218 #define LWP_DETACHED    0x00000040
  219 #define LWP_SUSPENDED   0x00000080
  220 #define __LWP_ASLWP     0x00000100 /* XXX more icky signal semantics */
  221 
  222 #endif  /* !_SYS_LWP_H_ */

Cache object: d9e6de1a2cb25b90b22b2248920219dd


[ 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.