4 * Implements inline procedure support for the LWKT subsystem.
6 * Generally speaking these routines only operate on threads associated
7 * with the current cpu. For example, a higher priority thread pending
8 * on a different cpu will not be immediately scheduled by a yield() on
11 * $DragonFly: src/sys/sys/thread2.h,v 1.1 2003/06/21 07:54:57 dillon Exp $
14 #ifndef _SYS_THREAD2_H_
15 #define _SYS_THREAD2_H_
18 * Critical sections prevent preemption by raising a thread's priority
19 * above the highest possible interrupting priority. Additionally, the
20 * current cpu will not be able to schedule a new thread but will instead
21 * place it on a pending list (with interrupts physically disabled) and
22 * set mycpu->gd_reqpri to indicate that work needs to be done, which
23 * lwkt_yield_quick() takes care of.
25 * Synchronous switching and blocking is allowed while in a critical section.
30 curthread->td_pri += TDPRI_CRIT;
34 crit_exit_noyield(void)
36 thread_t td = curthread;
38 td->td_pri -= TDPRI_CRIT;
39 KASSERT(td->td_pri >= 0, ("crit_exit nesting error"));
45 thread_t td = curthread;
47 td->td_pri -= TDPRI_CRIT;
48 KASSERT(td->td_pri >= 0, ("crit_exit nesting error"));
49 if (td->td_pri < mycpu->gd_reqpri)
54 lwkt_raisepri(int pri)
56 int opri = curthread->td_pri;
58 curthread->td_pri = pri;
63 lwkt_lowerpri(int pri)
65 thread_t td = curthread;
66 int opri = td->td_pri;
69 if (pri < mycpu->gd_reqpri)
78 curthread->td_pri = pri;
79 if (pri < mycpu->gd_reqpri)
84 lwkt_havetoken(lwkt_token_t tok)
86 return (tok->t_cpu == mycpu->gd_cpu);