version 1.169, 2014/05/16 10:05:38 |
version 1.169.4.2, 2016/07/09 20:25:24 |
|
|
#include <sys/resource.h> |
#include <sys/resource.h> |
|
|
#if defined(_KERNEL) |
#if defined(_KERNEL) |
|
struct lwp; |
|
/* forward declare this for <machine/cpu.h> so it can get l_cpu. */ |
|
static inline struct cpu_info *lwp_getcpu(struct lwp *); |
#include <machine/cpu.h> /* curcpu() and cpu_info */ |
#include <machine/cpu.h> /* curcpu() and cpu_info */ |
#endif |
#endif |
|
|
|
|
pri_t l_kpribase; /* !: kernel priority base level */ |
pri_t l_kpribase; /* !: kernel priority base level */ |
pri_t l_priority; /* l: scheduler priority */ |
pri_t l_priority; /* l: scheduler priority */ |
pri_t l_inheritedprio;/* l: inherited priority */ |
pri_t l_inheritedprio;/* l: inherited priority */ |
|
pri_t l_protectprio; /* l: for PTHREAD_PRIO_PROTECT */ |
|
pri_t l_auxprio; /* l: max(inherit,protect) priority */ |
|
int l_protectdepth; /* l: for PTHREAD_PRIO_PROTECT */ |
SLIST_HEAD(, turnstile) l_pi_lenders; /* l: ts lending us priority */ |
SLIST_HEAD(, turnstile) l_pi_lenders; /* l: ts lending us priority */ |
uint64_t l_ncsw; /* l: total context switches */ |
uint64_t l_ncsw; /* l: total context switches */ |
uint64_t l_nivcsw; /* l: involuntary context switches */ |
uint64_t l_nivcsw; /* l: involuntary context switches */ |
Line 400 lwp_lendpri(lwp_t *l, pri_t pri) |
|
Line 406 lwp_lendpri(lwp_t *l, pri_t pri) |
|
{ |
{ |
KASSERT(mutex_owned(l->l_mutex)); |
KASSERT(mutex_owned(l->l_mutex)); |
|
|
if (l->l_inheritedprio == pri) |
|
return; |
|
|
|
(*l->l_syncobj->sobj_lendpri)(l, pri); |
(*l->l_syncobj->sobj_lendpri)(l, pri); |
KASSERT(l->l_inheritedprio == pri); |
KASSERT(l->l_inheritedprio == pri); |
} |
} |
Line 415 lwp_eprio(lwp_t *l) |
|
Line 418 lwp_eprio(lwp_t *l) |
|
pri = l->l_priority; |
pri = l->l_priority; |
if ((l->l_flag & LW_SYSTEM) == 0 && l->l_kpriority && pri < PRI_KERNEL) |
if ((l->l_flag & LW_SYSTEM) == 0 && l->l_kpriority && pri < PRI_KERNEL) |
pri = (pri >> 1) + l->l_kpribase; |
pri = (pri >> 1) + l->l_kpribase; |
return MAX(l->l_inheritedprio, pri); |
return MAX(l->l_auxprio, pri); |
} |
} |
|
|
int lwp_create(lwp_t *, struct proc *, vaddr_t, int, |
int lwp_create(lwp_t *, struct proc *, vaddr_t, int, |
Line 467 extern struct lwp *curlwp; /* Current r |
|
Line 470 extern struct lwp *curlwp; /* Current r |
|
#endif /* ! curlwp */ |
#endif /* ! curlwp */ |
#define curproc (curlwp->l_proc) |
#define curproc (curlwp->l_proc) |
|
|
|
/* |
|
* This provide a way for <machine/cpu.h> to get l_cpu for curlwp before |
|
* struct lwp is defined. |
|
*/ |
|
static inline struct cpu_info * |
|
lwp_getcpu(struct lwp *l) |
|
{ |
|
return l->l_cpu; |
|
} |
|
|
static inline bool |
static inline bool |
CURCPU_IDLE_P(void) |
CURCPU_IDLE_P(void) |
{ |
{ |
Line 508 KPREEMPT_ENABLE(lwp_t *l) |
|
Line 521 KPREEMPT_ENABLE(lwp_t *l) |
|
#define DOPREEMPT_ACTIVE 0x01 |
#define DOPREEMPT_ACTIVE 0x01 |
#define DOPREEMPT_COUNTED 0x02 |
#define DOPREEMPT_COUNTED 0x02 |
|
|
|
/* |
|
* Prevent curlwp from migrating between CPUs beteen curlwp_bind and |
|
* curlwp_bindx. One use case is psref(9) that has a contract that |
|
* forbids migrations. |
|
*/ |
|
static inline int |
|
curlwp_bind(void) |
|
{ |
|
int bound; |
|
|
|
bound = curlwp->l_pflag & LP_BOUND; |
|
curlwp->l_pflag |= LP_BOUND; |
|
|
|
return bound; |
|
} |
|
|
|
static inline void |
|
curlwp_bindx(int bound) |
|
{ |
|
curlwp->l_pflag ^= bound ^ LP_BOUND; |
|
} |
|
|
#endif /* _KERNEL */ |
#endif /* _KERNEL */ |
|
|
/* Flags for _lwp_create(), as per Solaris. */ |
/* Flags for _lwp_create(), as per Solaris. */ |