summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2000-12-06 02:01:56 +0000
committerjhb <jhb@FreeBSD.org>2000-12-06 02:01:56 +0000
commitd096b69c0b828162b68f5ebbced4d746b203b684 (patch)
treed4f6b357e248b356a66f242fd571ce660ff7a478
parentf3679089a1182e143ad49a89eb78513e51ec6cf6 (diff)
downloadFreeBSD-src-d096b69c0b828162b68f5ebbced4d746b203b684.zip
FreeBSD-src-d096b69c0b828162b68f5ebbced4d746b203b684.tar.gz
- 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().
-rw-r--r--sys/sys/proc.h16
1 files 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;
OpenPOWER on IntegriCloud