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

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/sys/lwp.h between version 1.41 and 1.41.4.3

version 1.41, 2006/07/30 21:58:11 version 1.41.4.3, 2006/10/24 21:10:21
Line 1 
Line 1 
 /*      $NetBSD$        */  /*      $NetBSD$        */
   
 /*-  /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.   * Copyright (c) 2001, 2006 The NetBSD Foundation, Inc.
  * All rights reserved.   * All rights reserved.
  *   *
  * This code is derived from software contributed to The NetBSD Foundation   * This code is derived from software contributed to The NetBSD Foundation
Line 39 
Line 39 
 #ifndef _SYS_LWP_H_  #ifndef _SYS_LWP_H_
 #define _SYS_LWP_H_  #define _SYS_LWP_H_
   
   
 #if defined(_KERNEL)  #if defined(_KERNEL)
 #include <machine/cpu.h>                /* curcpu() and cpu_info */  #include <machine/cpu.h>                /* curcpu() and cpu_info */
 #endif  #endif
 #include <machine/proc.h>               /* Machine-dependent proc substruct. */  #include <machine/proc.h>               /* Machine-dependent proc substruct. */
 #include <sys/queue.h>  #include <sys/queue.h>
 #include <sys/callout.h>  #include <sys/callout.h>
   #include <sys/mutex.h>
   #include <sys/signalvar.h>
   
   typedef volatile const void *wchan_t;
   
   /*
    * Lightweight process.  Field markings and the corresponding locks:
    *
    * a:   alllwp_mutex
    * l:   *l->l_mutex
    * p:   p->p_smutex
    * (:   unlocked, stable
    * !:   unlocked, may only be safely accessed by the LWP itself
    * ?:   undecided
    */
 struct  lwp {  struct  lwp {
         struct  lwp *l_forw;            /* Doubly-linked run/sleep queue. */          struct lwp      *l_forw;        /* l: run queue */
         struct  lwp *l_back;          struct lwp      *l_back;        /* l: run queue */
         LIST_ENTRY(lwp) l_list;         /* Entry on list of all LWPs. */          kmutex_t * volatile l_mutex;    /* l: ptr to mutex on sched state */
           kmutex_t        *l_omutex;      /* l: mutex owned by lwp_lock() */
         struct proc *l_proc;    /* Process with which we are associated. */          struct cpu_info * volatile l_cpu; /* l: CPU we're on if LSONPROC */
           int             l_flag;         /* l: misc flag values */
         LIST_ENTRY(lwp) l_sibling;      /* Entry on process's list of LWPs. */          int             l_stat;         /* l: overall LWP status */
           struct turnstile *l_ts;         /* l: current turnstile */
         struct cpu_info * volatile l_cpu; /* CPU we're running on if  
                                                SONPROC */          lwpid_t         l_lid;          /* (: LWP identifier; local to proc */
         int     l_flag;  
         int     l_stat;          LIST_ENTRY(lwp) l_list;         /* a: entry on list of all LWPs */
         lwpid_t l_lid;          /* LWP identifier; local to process. */  
           struct proc     *l_proc;        /* p: parent process */
           LIST_ENTRY(lwp) l_sibling;      /* p: entry on proc's list of LWPs */
   
 #define l_startzero l_cred  #define l_startzero l_cred
         struct kauth_cred *l_cred;      /* Cached credentials */  
         u_short l_acflag;       /* Accounting flags */  
         u_int   l_swtime;       /* Time swapped in or out. */  
         u_int   l_slptime;      /* Time since last blocked. */  
   
         volatile const void *l_wchan;   /* Sleep address. */  
         struct callout l_tsleep_ch;     /* callout for tsleep */  
         const char *l_wmesg;    /* Reason for sleep. */  
         int     l_holdcnt;      /* If non-zero, don't swap. */  
         void    *l_ctxlink;     /* uc_link {get,set}context */  
         int     l_dupfd;        /* Sideways return value from cloning devices XXX */  
         struct sadata_vp *l_savp; /* SA "virtual processor" */  
   
         int     l_locks;        /* DEBUG: lockmgr count of held locks */  
         void    *l_private;     /* svr4-style lwp-private data */  
   
 #define l_endzero l_priority          struct kauth_cred *l_cred;      /* !: cached credentials */
           u_short         l_acflag;       /* !: accounting flags */
   
 #define l_startcopy l_priority          u_int           l_swtime;       /* l: time swapped in or out */
           u_int           l_slptime;      /* l: time since last blocked */
           int             l_locks;        /* l: lockmgr count of held locks */
           u_short         l_shlocks;      /* !: lockdebug: shared locks held */
           u_short         l_exlocks;      /* !: lockdebug: excl. locks held */
   
           int             l_holdcnt;      /* l: if non-zero, don't swap */
           TAILQ_ENTRY(lwp) l_sleepq;      /* l: sleep queue */
           wchan_t         l_wchan;        /* l: sleep address */
           struct callout  l_tsleep_ch;    /* l: callout for tsleep */
           const char      *l_wmesg;       /* l: reason for sleep */
           long            l_nvcsw;        /* l: voluntary context switches */
           long            l_nivcsw;       /* l: involuntary context switches */
           struct timeval  l_rtime;        /* l: real time */
   
           struct sadata_vp *l_savp;       /* ?: SA "virtual processor" */
   
           void            *l_private;     /* ?: svr4-style lwp-private data */
           void            *l_ctxlink;     /* ?: uc_link {get,set}context */
           int             l_dupfd;        /* ?: side return from cloning devs XXX */
   
           int             l_sigrestore;   /* p: need to restore old sig mask */
           stack_t         *l_sigstk;      /* p: sp & on stack state variable */
           sigpend_t       *l_sigpend;     /* p: signals to this LWP */
           sigset_t        *l_sigmask;     /* p: signal mask */
           sigset_t        *l_sigwait;     /* p: signals being waited for */
           struct ksiginfo *l_sigwaited;   /* p: delivered signals from set */
           LIST_ENTRY(lwp) l_sigwaiter;    /* p: chain on list of waiting LWPs */
           sigset_t        l_sigoldmask;   /* p: mask from before sigpause */
           sigstore_t      l_sigstore;     /* p: signal state for 1:1 threads */
   
         u_char  l_priority;     /* Process priority. */  #define l_endzero l_sigmask
         u_char  l_usrpri;       /* User-priority based on p_cpu and p_nice. */  
   #define l_startcopy l_sigmask
   
 #define l_endcopy l_emuldata  
   
         void    *l_emuldata;    /* kernel lwp-private data */          u_char          l_priority;     /* l: process priority */
           u_char          l_usrpri;       /* l: user-priority */
   
   #define l_endcopy l_emuldata
   
         struct  user *l_addr;   /* Kernel virtual addr of u-area (PROC ONLY). */          void            *l_emuldata;    /* !: kernel lwp-private data */
         struct  mdlwp l_md;     /* Any machine-dependent fields. */          struct user     *l_addr;        /* ?: KVA of u-area (PROC ONLY) */
           struct mdlwp    l_md;           /* ?: machine-dependent fields. */
 };  };
   
 #if !defined(USER_TO_UAREA)  #if !defined(USER_TO_UAREA)
Line 105  struct lwp {
Line 139  struct lwp {
 LIST_HEAD(lwplist, lwp);                /* a list of LWPs */  LIST_HEAD(lwplist, lwp);                /* a list of LWPs */
   
 #ifdef _KERNEL  #ifdef _KERNEL
   extern kmutex_t sched_mutex;            /* Mutex on global run queue */
   extern kmutex_t alllwp_mutex;           /* Mutex on alllwp */
   extern kmutex_t lwp_mutex;              /* Idle LWP mutex */
 extern struct lwplist alllwp;           /* List of all LWPs. */  extern struct lwplist alllwp;           /* List of all LWPs. */
   
 extern struct pool lwp_pool;            /* memory pool for LWPs */  extern struct pool lwp_pool;            /* memory pool for LWPs */
Line 117  extern struct lwp lwp0;   /* LWP for pro
Line 154  extern struct lwp lwp0;   /* LWP for pro
 #define L_INMEM         0x00000004 /* [*] Loaded into memory. */  #define L_INMEM         0x00000004 /* [*] Loaded into memory. */
 #define L_SELECT        0x00000040 /* [*] Selecting; wakeup/waiting danger. */  #define L_SELECT        0x00000040 /* [*] Selecting; wakeup/waiting danger. */
 #define L_SINTR         0x00000080 /* [*] Sleep is interruptible. */  #define L_SINTR         0x00000080 /* [*] Sleep is interruptible. */
   #define L_SYSTEM        0x00000200 /* [*] Kernel thread */
 #define L_SA            0x00000400 /* [*] Scheduler activations LWP */  #define L_SA            0x00000400 /* [*] Scheduler activations LWP */
   #define L_OWEUPC        0x00040000 /* Owe user profiling tick */
   #define L_WCORE         0x00080000 /* Stop for core dump on return to user */
   #define L_WEXIT         0x00100000 /* Exit before return to user */
 #define L_SA_UPCALL     0x00200000 /* SA upcall is pending */  #define L_SA_UPCALL     0x00200000 /* SA upcall is pending */
 #define L_SA_BLOCKING   0x00400000 /* Blocking in tsleep() */  #define L_SA_BLOCKING   0x00400000 /* Blocking in tsleep() */
 #define L_DETACHED      0x00800000 /* Won't be waited for. */  #define L_DETACHED      0x00800000 /* Won't be waited for. */
   #define L_PENDSIG       0x01000000 /* Pending signal for us */
 #define L_CANCELLED     0x02000000 /* tsleep should not sleep */  #define L_CANCELLED     0x02000000 /* tsleep should not sleep */
 #define L_SA_PAGEFAULT  0x04000000 /* SA LWP in pagefault handler */  #define L_SA_PAGEFAULT  0x04000000 /* SA LWP in pagefault handler */
 #define L_TIMEOUT       0x08000000 /* Timing out during sleep. */  
 #define L_SA_YIELD      0x10000000 /* LWP on VP is yielding */  #define L_SA_YIELD      0x10000000 /* LWP on VP is yielding */
 #define L_SA_IDLE       0x20000000 /* VP is idle */  #define L_SA_IDLE       0x20000000 /* VP is idle */
 #define L_COWINPROGRESS 0x40000000 /* UFS: doing copy on write */  #define L_COWINPROGRESS 0x40000000 /* UFS: doing copy on write */
 #define L_SA_SWITCHING  0x80000000 /* SA LWP in context switch */  #define L_SA_SWITCHING  0x80000000 /* SA LWP in context switch */
   
 /*  /*
    * Mask indicating that there is "exceptional" work to be done on return to
    * user.
    */
   #define L_USERRET       (L_WCORE|L_WEXIT|L_PENDSIG)
   
   /*
  * Status values.   * Status values.
  *   *
  * A note about SRUN and SONPROC: SRUN indicates that a process is   * A note about SRUN and SONPROC: SRUN indicates that a process is
Line 181  int cpu_switch (struct lwp *, struct lwp
Line 228  int cpu_switch (struct lwp *, struct lwp
 void    cpu_switchto (struct lwp *, struct lwp *);  void    cpu_switchto (struct lwp *, struct lwp *);
 #endif  #endif
   
   int     lwp_locked(struct lwp *, kmutex_t *);
   void    lwp_setlock(struct lwp *, kmutex_t *);
   void    lwp_setlock_unlock(struct lwp *, kmutex_t *);
   void    lwp_lock(struct lwp *l);
   void    lwp_relock(struct lwp *l, kmutex_t *);
   void    lwp_unlock(struct lwp *l);
   
 int newlwp(struct lwp *, struct proc *, vaddr_t, int /* XXX boolean_t */, int,  int newlwp(struct lwp *, struct proc *, vaddr_t, int /* XXX boolean_t */, int,
     void *, size_t, void (*)(void *), void *, struct lwp **);      void *, size_t, void (*)(void *), void *, struct lwp **);
   
Line 193  void startlwp(void *);
Line 247  void startlwp(void *);
 void    upcallret(struct lwp *);  void    upcallret(struct lwp *);
 void    lwp_exit (struct lwp *);  void    lwp_exit (struct lwp *);
 void    lwp_exit2 (struct lwp *);  void    lwp_exit2 (struct lwp *);
 struct lwp *proc_representative_lwp(struct proc *);  struct lwp *proc_representative_lwp(struct proc *, int *, int);
 __inline int lwp_suspend(struct lwp *, struct lwp *);  int     lwp_halt(struct lwp *, struct lwp *, int);
 int     lwp_create1(struct lwp *, const void *, size_t, u_long, lwpid_t *);  int     lwp_create1(struct lwp *, const void *, size_t, u_long, lwpid_t *);
 void    lwp_update_creds(struct lwp *);  void    lwp_update_creds(struct lwp *);
   struct lwp *lwp_byid(struct proc *, int);
   void    lwp_userret(struct lwp *);
   int     lwp_lastlive(int);
 #endif  /* _KERNEL */  #endif  /* _KERNEL */
   
 /* Flags for _lwp_create(), as per Solaris. */  /* Flags for _lwp_create(), as per Solaris. */

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.41.4.3

CVSweb <webmaster@jp.NetBSD.org>