[BACK]Return to lwp.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / sys

Annotation of src/sys/sys/lwp.h, Revision 1.11

1.11    ! cl          1: /*     $NetBSD: lwp.h,v 1.10 2003/09/13 08:32:18 jdolecek Exp $        */
1.2       thorpej     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/ucontext.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:        LIST_ENTRY(lwp) l_zlist;        /* Entry on zombie list.  */
                     56:
                     57:        struct proc *l_proc;    /* Process with which we are associated. */
                     58:
                     59:        LIST_ENTRY(lwp) l_sibling;      /* Entry on process's list of LWPs. */
                     60:
                     61:        struct cpu_info * __volatile l_cpu; /* CPU we're running on if
                     62:                                               SONPROC */
1.5       matt       63:        int     l_flag;
1.2       thorpej    64:        int     l_stat;
                     65:        lwpid_t l_lid;          /* LWP identifier; local to process. */
                     66:
                     67: #define l_startzero l_swtime
                     68:        u_int   l_swtime;       /* Time swapped in or out. */
                     69:        u_int   l_slptime;      /* Time since last blocked. */
                     70:
1.6       yamt       71:        const void *l_wchan;    /* Sleep address. */
1.2       thorpej    72:        struct callout l_tsleep_ch;     /* callout for tsleep */
                     73:        const char *l_wmesg;    /* Reason for sleep. */
                     74:        int     l_holdcnt;      /* If non-zero, don't swap. */
1.9       jdolecek   75:        void    *l_ctxlink;     /* uc_link {get,set}context */
1.10      jdolecek   76:        int     l_dupfd;        /* Sideways return value from cloning devices XXX */
1.11    ! cl         77:        void    *l_upcallstack; /* Upcall stack used during blocking upcall */
1.2       thorpej    78:
                     79: #define l_endzero l_priority
                     80:
                     81: #define l_startcopy l_priority
                     82:
                     83:        u_char  l_priority;     /* Process priority. */
                     84:        u_char  l_usrpri;       /* User-priority based on p_cpu and p_nice. */
                     85:
                     86: #define l_endcopy l_private
                     87:
                     88:        void    *l_private;     /* svr4-style lwp-private data */
1.4       manu       89: #ifdef notyet
1.3       matt       90:        void    *l_emuldata;    /* kernel lwp-private data */
1.4       manu       91: #endif
1.2       thorpej    92:
                     93:        int     l_locks;        /* DEBUG: lockmgr count of held locks */
                     94:
                     95:        struct  user *l_addr;   /* Kernel virtual addr of u-area (PROC ONLY). */
                     96:        struct  mdlwp l_md;     /* Any machine-dependent fields. */
                     97:
                     98: };
                     99:
                    100: LIST_HEAD(lwplist, lwp);               /* a list of LWPs */
                    101:
                    102: extern struct lwplist alllwp;          /* List of all LWPs. */
                    103: extern struct lwplist deadlwp;         /* */
                    104: extern struct lwplist zomblwp;
                    105:
                    106: extern struct pool lwp_pool;           /* memory pool for LWPs */
                    107: extern struct pool lwp_uc_pool;                /* memory pool for LWP startup args */
                    108:
                    109: extern struct lwp lwp0;                        /* LWP for proc0 */
                    110:
                    111: /* These flags are kept in l_flag. */
                    112: #define        L_INMEM         0x00004 /* Loaded into memory. */
                    113: #define        L_SELECT        0x00040 /* Selecting; wakeup/waiting danger. */
                    114: #define        L_SINTR         0x00080 /* Sleep is interruptible. */
                    115: #define        L_TIMEOUT       0x00400 /* Timing out during sleep. */
                    116: #define        L_BIGLOCK       0x80000 /* LWP needs kernel "big lock" to run */
                    117: #define        L_SA            0x100000 /* Scheduler activations LWP */
                    118: #define        L_SA_UPCALL     0x200000 /* SA upcall is pending */
                    119: #define        L_SA_BLOCKING   0x400000 /* Blocking in tsleep() */
                    120: #define        L_DETACHED      0x800000 /* Won't be waited for. */
1.7       fvdl      121: #define L_SA_WANTS_VP   0x1000000 /* SA LWP wants a virtual processor */
1.8       matt      122: #define        L_CANCELLED     0x2000000 /* tsleep should not sleep */
1.11    ! cl        123: #define L_SA_PAGEFAULT 0x4000000 /* SA LWP in pagefault handler */
1.2       thorpej   124:
                    125: /*
                    126:  * Status values.
                    127:  *
                    128:  * A note about SRUN and SONPROC: SRUN indicates that a process is
                    129:  * runnable but *not* yet running, i.e. is on a run queue.  SONPROC
                    130:  * indicates that the process is actually executing on a CPU, i.e.
                    131:  * it is no longer on a run queue.
                    132:  */
                    133: #define        LSIDL   1               /* Process being created by fork. */
                    134: #define        LSRUN   2               /* Currently runnable. */
                    135: #define        LSSLEEP 3               /* Sleeping on an address. */
                    136: #define        LSSTOP  4               /* Process debugging or suspension. */
                    137: #define        LSZOMB  5               /* Awaiting collection by parent. */
                    138: #define        LSDEAD  6               /* Process is almost a zombie. */
                    139: #define        LSONPROC        7       /* Process is currently on a CPU. */
                    140: #define        LSSUSPENDED     8       /* Not running, not signalable. */
                    141:
                    142: #ifdef _KERNEL
                    143: #define        PHOLD(l)                                                        \
                    144: do {                                                                   \
                    145:        if ((l)->l_holdcnt++ == 0 && ((l)->l_flag & L_INMEM) == 0)      \
                    146:                uvm_swapin(l);                                          \
                    147: } while (/* CONSTCOND */ 0)
                    148: #define        PRELE(l)        (--(l)->l_holdcnt)
                    149:
                    150:
                    151: void   preempt (int);
                    152: int    mi_switch (struct lwp *, struct lwp *);
                    153: #ifndef remrunqueue
                    154: void   remrunqueue (struct lwp *);
                    155: #endif
                    156: void   resetpriority (struct lwp *);
                    157: void   setrunnable (struct lwp *);
                    158: #ifndef setrunqueue
                    159: void   setrunqueue (struct lwp *);
                    160: #endif
                    161: #ifndef nextrunqueue
                    162: struct lwp *nextrunqueue(void);
                    163: #endif
                    164: void   unsleep (struct lwp *);
                    165: #ifndef cpu_switch
                    166: int    cpu_switch (struct lwp *, struct lwp *);
                    167: #endif
                    168: #ifndef cpu_switchto
                    169: void   cpu_switchto (struct lwp *, struct lwp *);
                    170: #endif
                    171:
                    172: int newlwp(struct lwp *, struct proc *, vaddr_t, int /* XXX boolean_t */, int,
                    173:     void *, size_t, void (*)(void *), void *, struct lwp **);
                    174:
                    175: /* Flags for _lwp_wait1 */
                    176: #define LWPWAIT_EXITCONTROL    0x00000001
                    177: int    lwp_wait1(struct lwp *, lwpid_t, lwpid_t *, int);
                    178: void   lwp_continue(struct lwp *);
                    179: void   cpu_setfunc(struct lwp *, void (*)(void *), void *);
                    180: void   startlwp(void *);
                    181: void   upcallret(struct lwp *);
                    182: void   lwp_exit (struct lwp *);
                    183: void   lwp_exit2 (struct lwp *);
                    184: struct lwp *proc_representative_lwp(struct proc *);
                    185: #endif /* _KERNEL */
                    186:
                    187: /* Flags for _lwp_create(), as per Solaris. */
                    188:
                    189: #define LWP_DETACHED    0x00000040
                    190: #define LWP_SUSPENDED   0x00000080
                    191: #define __LWP_ASLWP     0x00000100 /* XXX more icky signal semantics */
                    192:
                    193: #endif /* !_SYS_LWP_H_ */
                    194:

CVSweb <webmaster@jp.NetBSD.org>