From ab26caf6afdbc3a113e877fdd826e1fe50ca4e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 15 Apr 2007 12:59:49 +0000 Subject: [PATCH] Add macros to assert that the process is / isn't held in memory. MFC after: 3 weeks --- sys/sys/proc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 72b171e7b5b..7d71b8cc2dd 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -746,6 +746,9 @@ MALLOC_DECLARE(M_ZOMBIE); if (((p)->p_sflag & PS_INMEM) == 0) \ faultin((p)); \ } while (0) +#define PROC_ASSERT_HELD(p) do { \ + KASSERT((p)->p_lock > 0, ("process not held")); \ +} while (0) #define PRELE(p) do { \ PROC_LOCK((p)); \ @@ -758,6 +761,9 @@ MALLOC_DECLARE(M_ZOMBIE); if (((p)->p_flag & P_WEXIT) && (p)->p_lock == 0) \ wakeup(&(p)->p_lock); \ } while (0) +#define PROC_ASSERT_NOT_HELD(p) do { \ + KASSERT((p)->p_lock == 0, ("process held")); \ +} while (0) /* Check whether a thread is safe to be swapped out. */ #define thread_safetoswapout(td) (TD_IS_SLEEPING(td) || TD_IS_SUSPENDED(td))