diff options
author | John Baldwin <jhb@FreeBSD.org> | 2005-09-26 19:43:37 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2005-09-26 19:43:37 +0000 |
commit | a630fc3f14faa754a8076621973cf1d12c066d89 (patch) | |
tree | 4d860abef74a808ec650dca73fd8e581574c9435 | |
parent | d4accbfec7fdb7c1c87d4a993046dcb10d97ce5b (diff) |
Notes
-rw-r--r-- | sys/kern/subr_sleepqueue.c | 4 | ||||
-rw-r--r-- | sys/sys/proc.h | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c index 44a2596d29e6..3def26335a01 100644 --- a/sys/kern/subr_sleepqueue.c +++ b/sys/kern/subr_sleepqueue.c @@ -269,6 +269,10 @@ sleepq_add(void *wchan, struct mtx *lock, const char *wmesg, int flags) MPASS(td->td_sleepqueue != NULL); MPASS(wchan != NULL); + /* If this thread is not allowed to sleep, die a horrible death. */ + KASSERT(!(td->td_pflags & TDP_NOSLEEPING), + ("trying to sleep while sleeping is prohibited")); + /* Look up the sleep queue associated with the wait channel 'wchan'. */ sq = sleepq_lookup(wchan); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index a408ecccb670..0bdf303d0ab4 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -368,7 +368,7 @@ struct thread { #define TDP_ALTSTACK 0x00000020 /* Have alternate signal stack. */ #define TDP_DEADLKTREAT 0x00000040 /* Lock aquisition - deadlock treatment. */ #define TDP_SA 0x00000080 /* A scheduler activation based thread. */ -#define TDP_UNUSED8 0x00000100 /* --available -- */ +#define TDP_NOSLEEPING 0x00000100 /* Thread is not allowed to sleep on a sq. */ #define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */ #define TDP_UNUSED10 0x00000400 /* --available -- */ #define TDP_CAN_UNBIND 0x00000800 /* Only temporarily bound. */ @@ -793,6 +793,19 @@ MALLOC_DECLARE(M_ZOMBIE); /* Check whether a thread is safe to be swapped out. */ #define thread_safetoswapout(td) (TD_IS_SLEEPING(td) || TD_IS_SUSPENDED(td)) +/* Control whether or not it is safe for curthread to sleep. */ +#define THREAD_NO_SLEEPING() do { \ + KASSERT(!(curthread->td_pflags & TDP_NOSLEEPING), \ + ("nested no sleeping")); \ + curthread->td_pflags |= TDP_NOSLEEPING; \ +} while (0) + +#define THREAD_SLEEPING_OK() do { \ + KASSERT((curthread->td_pflags & TDP_NOSLEEPING), \ + ("nested sleeping ok")); \ + curthread->td_pflags &= ~TDP_NOSLEEPING; \ +} while (0) + /* Lock and unlock process arguments. */ #define PARGS_LOCK(p) mtx_lock(&pargs_ref_lock) #define PARGS_UNLOCK(p) mtx_unlock(&pargs_ref_lock) |