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.5 2003/07/06 21:23:54 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 struct thread *td = curthread;
34 td->td_pri += TDPRI_CRIT;
38 crit_exit_noyield(void)
40 thread_t td = curthread;
42 td->td_pri -= TDPRI_CRIT;
50 thread_t td = curthread;
52 td->td_pri -= TDPRI_CRIT;
55 if (td->td_pri < mycpu->gd_reqpri)
62 thread_t td = curthread;
64 td->td_pri = td->td_pri & TDPRI_MASK;
69 crit_panic_restore(int cpri)
71 curthread->td_pri = cpri;
75 lwkt_havetoken(lwkt_token_t tok)
77 return (tok->t_cpu == mycpu->gd_cpuid);
83 return (mycpu->gd_runqmask != 0);