Module Name: src Committed By: thorpej Date: Fri May 8 03:26:51 UTC 2020
Modified Files: src/sys/kern: kern_sleepq.c src/sys/sys: sleepq.h Log Message: Add a new function, sleepq_transfer(), that moves an lwp from one sleepq to another. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/kern/kern_sleepq.c cvs rdiff -u -r1.29 -r1.30 src/sys/sys/sleepq.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_sleepq.c diff -u src/sys/kern/kern_sleepq.c:1.66 src/sys/kern/kern_sleepq.c:1.67 --- src/sys/kern/kern_sleepq.c:1.66 Sun Apr 19 20:35:29 2020 +++ src/sys/kern/kern_sleepq.c Fri May 8 03:26:51 2020 @@ -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_enqueue(sleepq_t *sq, wchan_t wch } /* + * 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. Index: src/sys/sys/sleepq.h diff -u src/sys/sys/sleepq.h:1.29 src/sys/sys/sleepq.h:1.30 --- src/sys/sys/sleepq.h:1.29 Sun Apr 19 20:35:29 2020 +++ src/sys/sys/sleepq.h Fri May 8 03:26:51 2020 @@ -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 @@ typedef struct sleeptab { 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 *);