From d096b69c0b828162b68f5ebbced4d746b203b684 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 6 Dec 2000 02:01:56 +0000 Subject: - Add in PROC_LOCK() and PROC_UNLOCK() macros. For now these do simple mutex operations. In the future they may call functions that verify correct locking order between processes in the INVARIANTS case. - Lock the process in PHOLD() and PREL(). --- sys/sys/proc.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index beed079..d29b636908 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -383,12 +383,24 @@ sigonstack(size_t sp) } \ } while (0) +/* Lock and unlock a process. */ +#define PROC_LOCK(p) mtx_enter(&(p)->p_mtx, MTX_DEF) +#define PROC_UNLOCK(p) mtx_exit(&(p)->p_mtx, MTX_DEF) + /* Hold process U-area in memory, normally for ptrace/procfs work. */ #define PHOLD(p) do { \ - if ((p)->p_lock++ == 0 && ((p)->p_flag & P_INMEM) == 0) \ + PROC_LOCK(p); \ + if ((p)->p_lock++ == 0 && ((p)->p_flag & P_INMEM) == 0) { \ + PROC_UNLOCK(p); \ faultin(p); \ + } else \ + PROC_UNLOCK(p); \ +} while(0) +#define PRELE(p) do { \ + PROC_LOCK(p); \ + (--(p)->p_lock); \ + PROC_UNLOCK(p); \ } while(0) -#define PRELE(p) (--(p)->p_lock) #define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash]) extern LIST_HEAD(pidhashhead, proc) *pidhashtbl; -- cgit v1.1