summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2020-01-21 15:20:47 +0000
committervisa <visa@openbsd.org>2020-01-21 15:20:47 +0000
commit1021dd3d027b31effd3975d80598b0ea0412dae3 (patch)
tree4f1272143ceda9114f2e6c29c22139f7b92b28f7 /sys/kern/kern_fork.c
parentNo need to pass peerid to lsa_snap() (diff)
downloadwireguard-openbsd-1021dd3d027b31effd3975d80598b0ea0412dae3.tar.xz
wireguard-openbsd-1021dd3d027b31effd3975d80598b0ea0412dae3.zip
Make __thrsleep(2) and __thrwakeup(2) MP-safe
Threads in __thrsleep(2) are tracked using queues, one queue per each process for synchronization between threads of a process, and one system-wide queue for the special ident -1 handling. Each of these queues has an associated rwlock that serializes access. The queue lock is released when calling copyin() and copyout() in thrsleep(). This preserves the existing behaviour where a blocked copy operation does not prevent other threads from making progress. Tested by anton@, claudio@ OK anton@, claudio@, tedu@, mpi@
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index a9eebaaa35c..1f74865ed6a 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.220 2020/01/06 10:25:10 visa Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.221 2020/01/21 15:20:47 visa Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -191,7 +191,9 @@ process_initialize(struct process *pr, struct proc *p)
LIST_INIT(&pr->ps_children);
LIST_INIT(&pr->ps_ftlist);
LIST_INIT(&pr->ps_sigiolst);
+ TAILQ_INIT(&pr->ps_tslpqueue);
+ rw_init(&pr->ps_lock, "pslock");
mtx_init(&pr->ps_mtx, IPL_MPFLOOR);
timeout_set(&pr->ps_realit_to, realitexpire, pr);