Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - make lendpri/changepri similar.
details: https://anonhg.NetBSD.org/src/rev/bc9afa4194fa
branches: trunk
changeset: 770729:bc9afa4194fa
user: yamt <yamt%NetBSD.org@localhost>
date: Mon Oct 31 12:18:32 2011 +0000
description:
- make lendpri/changepri similar.
- make common code a subroutine.
diffstat:
sys/kern/kern_sleepq.c | 69 +++++++++++++++++++++----------------------------
sys/sys/lwp.h | 7 ++++-
2 files changed, 36 insertions(+), 40 deletions(-)
diffs (136 lines):
diff -r 57040b0c092d -r bc9afa4194fa sys/kern/kern_sleepq.c
--- a/sys/kern/kern_sleepq.c Mon Oct 31 08:28:46 2011 +0000
+++ b/sys/kern/kern_sleepq.c Mon Oct 31 12:18:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sleepq.c,v 1.43 2011/09/03 10:28:33 christos Exp $ */
+/* $NetBSD: kern_sleepq.c,v 1.44 2011/10/31 12:18:32 yamt Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.43 2011/09/03 10:28:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.44 2011/10/31 12:18:32 yamt Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -422,26 +422,16 @@
}
/*
- * sleepq_changepri:
+ * sleepq_reinsert:
*
- * Adjust the priority of an LWP residing on a sleepq. This method
- * will only alter the user priority; the effective priority is
- * assumed to have been fixed at the time of insertion into the queue.
+ * Move the possition of the lwp in the sleep queue after a possible
+ * change of the lwp's effective priority.
*/
-void
-sleepq_changepri(lwp_t *l, pri_t pri)
+static void
+sleepq_reinsert(sleepq_t *sq, lwp_t *l)
{
- sleepq_t *sq = l->l_sleepq;
- pri_t opri;
- KASSERT(lwp_locked(l, NULL));
-
- opri = lwp_eprio(l);
- l->l_priority = pri;
-
- if (lwp_eprio(l) == opri) {
- return;
- }
+ KASSERT(l->l_sleepq == sq);
if ((l->l_syncobj->sobj_flag & SOBJ_SLEEPQ_SORTED) == 0) {
return;
}
@@ -459,33 +449,34 @@
sleepq_insert(sq, l, l->l_syncobj);
}
+/*
+ * sleepq_changepri:
+ *
+ * Adjust the priority of an LWP residing on a sleepq.
+ */
+void
+sleepq_changepri(lwp_t *l, pri_t pri)
+{
+ sleepq_t *sq = l->l_sleepq;
+
+ KASSERT(lwp_locked(l, NULL));
+
+ l->l_priority = pri;
+ sleepq_reinsert(sq, l);
+}
+
+/*
+ * sleepq_changepri:
+ *
+ * Adjust the lended priority of an LWP residing on a sleepq.
+ */
void
sleepq_lendpri(lwp_t *l, pri_t pri)
{
sleepq_t *sq = l->l_sleepq;
- pri_t opri;
KASSERT(lwp_locked(l, NULL));
- opri = lwp_eprio(l);
l->l_inheritedprio = pri;
-
- if (lwp_eprio(l) == opri) {
- return;
- }
- if ((l->l_syncobj->sobj_flag & SOBJ_SLEEPQ_SORTED) == 0) {
- return;
- }
-
- /*
- * Don't let the sleep queue become empty, even briefly.
- * cv_signal() and cv_broadcast() inspect it without the
- * sleep queue lock held and need to see a non-empty queue
- * head if there are waiters.
- */
- if (TAILQ_FIRST(sq) == l && TAILQ_NEXT(l, l_sleepchain) == NULL) {
- return;
- }
- TAILQ_REMOVE(sq, l, l_sleepchain);
- sleepq_insert(sq, l, l->l_syncobj);
+ sleepq_reinsert(sq, l);
}
diff -r 57040b0c092d -r bc9afa4194fa sys/sys/lwp.h
--- a/sys/sys/lwp.h Mon Oct 31 08:28:46 2011 +0000
+++ b/sys/sys/lwp.h Mon Oct 31 12:18:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lwp.h,v 1.155 2011/08/07 21:13:06 rmind Exp $ */
+/* $NetBSD: lwp.h,v 1.156 2011/10/31 12:18:32 yamt Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010
@@ -392,7 +392,11 @@
{
KASSERT(mutex_owned(l->l_mutex));
+ if (l->l_priority == pri)
+ return;
+
(*l->l_syncobj->sobj_changepri)(l, pri);
+ KASSERT(l->l_priority == pri);
}
static inline void
@@ -404,6 +408,7 @@
return;
(*l->l_syncobj->sobj_lendpri)(l, pri);
+ KASSERT(l->l_inheritedprio == pri);
}
static inline pri_t
Home |
Main Index |
Thread Index |
Old Index