Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add a new function, sleepq_transfer(), that moves an lwp...
details: https://anonhg.NetBSD.org/src/rev/397c12f38724
branches: trunk
changeset: 971904:397c12f38724
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri May 08 03:26:51 2020 +0000
description:
Add a new function, sleepq_transfer(), that moves an lwp from one
sleepq to another.
diffstat:
sys/kern/kern_sleepq.c | 36 ++++++++++++++++++++++++++++++++++--
sys/sys/sleepq.h | 6 ++++--
2 files changed, 38 insertions(+), 4 deletions(-)
diffs (77 lines):
diff -r 70505bc2426d -r 397c12f38724 sys/kern/kern_sleepq.c
--- a/sys/kern/kern_sleepq.c Fri May 08 00:54:44 2020 +0000
+++ b/sys/kern/kern_sleepq.c Fri May 08 03:26:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sleepq.c,v 1.66 2020/04/19 20:35:29 ad Exp $ */
+/* $NetBSD: kern_sleepq.c,v 1.67 2020/05/08 03:26:51 thorpej Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.66 2020/04/19 20:35:29 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.67 2020/05/08 03:26:51 thorpej Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -237,6 +237,38 @@
}
/*
+ * sleepq_transfer:
+ *
+ * Move an LWP from one sleep queue to another. Both sleep queues
+ * must already be locked.
+ *
+ * The LWP will be updated with the new sleepq, wchan, wmesg,
+ * sobj, and mutex. The interruptible flag will also be updated.
+ */
+void
+sleepq_transfer(lwp_t *l, sleepq_t *from_sq, sleepq_t *sq, wchan_t wchan,
+ const char *wmesg, syncobj_t *sobj, kmutex_t *mp, bool catch_p)
+{
+
+ KASSERT(l->l_sleepq == from_sq);
+
+ LIST_REMOVE(l, l_sleepchain);
+ l->l_syncobj = sobj;
+ l->l_wchan = wchan;
+ l->l_sleepq = sq;
+ l->l_wmesg = wmesg;
+
+ if (catch_p)
+ l->l_flag |= LW_SINTR;
+ else
+ l->l_flag &= ~LW_SINTR;
+
+ lwp_setlock(l, mp);
+
+ sleepq_insert(sq, l, sobj);
+}
+
+/*
* sleepq_block:
*
* After any intermediate step such as releasing an interlock, switch.
diff -r 70505bc2426d -r 397c12f38724 sys/sys/sleepq.h
--- a/sys/sys/sleepq.h Fri May 08 00:54:44 2020 +0000
+++ b/sys/sys/sleepq.h Fri May 08 03:26:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sleepq.h,v 1.29 2020/04/19 20:35:29 ad Exp $ */
+/* $NetBSD: sleepq.h,v 1.30 2020/05/08 03:26:51 thorpej Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020
@@ -61,7 +61,9 @@
void sleepq_init(sleepq_t *);
void sleepq_remove(sleepq_t *, lwp_t *);
void sleepq_enqueue(sleepq_t *, wchan_t, const char *, struct syncobj *,
- bool);
+ bool);
+void sleepq_transfer(lwp_t *, sleepq_t *, sleepq_t *, wchan_t, const char *,
+ struct syncobj *, kmutex_t *, bool);
void sleepq_unsleep(lwp_t *, bool);
void sleepq_timeout(void *);
void sleepq_wake(sleepq_t *, wchan_t, u_int, kmutex_t *);
Home |
Main Index |
Thread Index |
Old Index