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.26.2.2 2006/04/07 12:27:23 tron 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 
   50 struct  lwp {
   51         struct  lwp *l_forw;            /* Doubly-linked run/sleep queue. */
   52         struct  lwp *l_back;
   53         LIST_ENTRY(lwp) l_list;         /* Entry on list of all LWPs. */
   54 
   55         struct proc *l_proc;    /* Process with which we are associated. */
   56 
   57         LIST_ENTRY(lwp) l_sibling;      /* Entry on process's list of LWPs. */
   58 
   59         struct cpu_info * __volatile l_cpu; /* CPU we're running on if
   60                                                SONPROC */
   61         int     l_flag;
   62         int     l_stat;
   63         lwpid_t l_lid;          /* LWP identifier; local to process. */
   64 
   65 #define l_startzero l_swtime
   66         u_int   l_swtime;       /* Time swapped in or out. */
   67         u_int   l_slptime;      /* Time since last blocked. */
   68 
   69         const void *l_wchan;    /* Sleep address. */
   70         struct callout l_tsleep_ch;     /* callout for tsleep */
   71         const char *l_wmesg;    /* Reason for sleep. */
   72         int     l_holdcnt;      /* If non-zero, don't swap. */
   73         void    *l_ctxlink;     /* uc_link {get,set}context */
   74         int     l_dupfd;        /* Sideways return value from cloning devices XXX */
   75         struct sadata_vp *l_savp; /* SA "virtual processor" */
   76 
   77         int     l_locks;        /* DEBUG: lockmgr count of held locks */
   78         void    *l_private;     /* svr4-style lwp-private data */
   79 
   80 #define l_endzero l_priority
   81 
   82 #define l_startcopy l_priority
   83 
   84         u_char  l_priority;     /* Process priority. */
   85         u_char  l_usrpri;       /* User-priority based on p_cpu and p_nice. */
   86 
   87 #define l_endcopy l_emuldata
   88 
   89         void    *l_emuldata;    /* kernel lwp-private data */
   90 
   91         struct  user *l_addr;   /* Kernel virtual addr of u-area (PROC ONLY). */
   92         struct  mdlwp l_md;     /* Any machine-dependent fields. */
   93 };
   94 
   95 LIST_HEAD(lwplist, lwp);                /* a list of LWPs */
   96 
   97 extern struct lwplist alllwp;           /* List of all LWPs. */
   98 
   99 extern struct pool lwp_pool;            /* memory pool for LWPs */
  100 extern struct pool lwp_uc_pool;         /* memory pool for LWP startup args */
  101 
  102 extern struct lwp lwp0;                 /* LWP for proc0 */
  103 
  104 /* These flags are kept in l_flag. [*] is shared with p_flag */
  105 #define L_INMEM         0x00000004 /* [*] Loaded into memory. */
  106 #define L_SELECT        0x00000040 /* [*] Selecting; wakeup/waiting danger. */
  107 #define L_SINTR         0x00000080 /* [*] Sleep is interruptible. */
  108 #define L_TIMEOUT       0x00000400 /* Timing out during sleep. */
  109 #define L_PROCEXIT      0x00000800 /* In process exit, l_proc no longer valid */
  110 #define L_SA            0x00100000 /* Scheduler activations LWP */
  111 #define L_SA_UPCALL     0x00200000 /* SA upcall is pending */
  112 #define L_SA_BLOCKING   0x00400000 /* Blocking in tsleep() */
  113 #define L_DETACHED      0x00800000 /* Won't be waited for. */
  114 #define L_CANCELLED     0x02000000 /* tsleep should not sleep */
  115 #define L_SA_PAGEFAULT  0x04000000 /* SA LWP in pagefault handler */
  116 #define L_SA_YIELD      0x10000000 /* LWP on VP is yielding */
  117 #define L_SA_IDLE       0x20000000 /* VP is idle */
  118 #define L_COWINPROGRESS 0x40000000 /* UFS: doing copy on write */
  119 #define L_SA_SWITCHING  0x80000000 /* SA LWP in context switch */
  120 
  121 /*
  122  * Status values.
  123  *
  124  * A note about SRUN and SONPROC: SRUN indicates that a process is
  125  * runnable but *not* yet running, i.e. is on a run queue.  SONPROC
  126  * indicates that the process is actually executing on a CPU, i.e.
  127  * it is no longer on a run queue.
  128  */
  129 #define LSIDL   1               /* Process being created by fork. */
  130 #define LSRUN   2               /* Currently runnable. */
  131 #define LSSLEEP 3               /* Sleeping on an address. */
  132 #define LSSTOP  4               /* Process debugging or suspension. */
  133 #define LSZOMB  5               /* Awaiting collection by parent. */
  134 #define LSDEAD  6               /* Process is almost a zombie. */
  135 #define LSONPROC        7       /* Process is currently on a CPU. */
  136 #define LSSUSPENDED     8       /* Not running, not signalable. */
  137 
  138 #ifdef _KERNEL
  139 #define PHOLD(l)                                                        \
  140 do {                                                                    \
  141         if ((l)->l_holdcnt++ == 0 && ((l)->l_flag & L_INMEM) == 0)      \
  142                 uvm_swapin(l);                                          \
  143 } while (/* CONSTCOND */ 0)
  144 #define PRELE(l)        (--(l)->l_holdcnt)
  145 
  146 
  147 void    preempt (int);
  148 int     mi_switch (struct lwp *, struct lwp *);
  149 #ifndef remrunqueue
  150 void    remrunqueue (struct lwp *);
  151 #endif
  152 void    resetpriority (struct lwp *);
  153 void    setrunnable (struct lwp *);
  154 #ifndef setrunqueue
  155 void    setrunqueue (struct lwp *);
  156 #endif
  157 #ifndef nextrunqueue
  158 struct lwp *nextrunqueue(void);
  159 #endif
  160 void    unsleep (struct lwp *);
  161 #ifndef cpu_switch
  162 int     cpu_switch (struct lwp *, struct lwp *);
  163 #endif
  164 #ifndef cpu_switchto
  165 void    cpu_switchto (struct lwp *, struct lwp *);
  166 #endif
  167 
  168 int newlwp(struct lwp *, struct proc *, vaddr_t, int /* XXX boolean_t */, int,
  169     void *, size_t, void (*)(void *), void *, struct lwp **);
  170 
  171 /* Flags for _lwp_wait1 */
  172 #define LWPWAIT_EXITCONTROL     0x00000001
  173 int     lwp_wait1(struct lwp *, lwpid_t, lwpid_t *, int);
  174 void    lwp_continue(struct lwp *);
  175 void    cpu_setfunc(struct lwp *, void (*)(void *), void *);
  176 void    startlwp(void *);
  177 void    upcallret(struct lwp *);
  178 void    lwp_exit (struct lwp *);
  179 void    lwp_exit2 (struct lwp *);
  180 struct lwp *proc_representative_lwp(struct proc *);
  181 inline int lwp_suspend(struct lwp *, struct lwp *);
  182 #endif  /* _KERNEL */
  183 
  184 /* Flags for _lwp_create(), as per Solaris. */
  185 
  186 #define LWP_DETACHED    0x00000040
  187 #define LWP_SUSPENDED   0x00000080
  188 #define __LWP_ASLWP     0x00000100 /* XXX more icky signal semantics */
  189 
  190 #endif  /* !_SYS_LWP_H_ */
  191 

Cache object: 5ac05723e178d2a10b7d061637e2c110


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