Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jul 2004 01:12:53 GMT
From:      Julian Elischer <julian@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 57669 for review
Message-ID:  <200407190112.i6J1Cr1U010556@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=57669

Change 57669 by julian@julian_desk on 2004/07/19 01:11:56

	Catch up with the system version of kern_switch.c.

Affected files ...

.. //depot/projects/nsched/sys/kern/sched_4bsd.c#27 edit
.. //depot/projects/nsched/sys/kern/sched_ule.c#15 edit

Differences ...

==== //depot/projects/nsched/sys/kern/sched_4bsd.c#27 (text+ko) ====

@@ -1838,7 +1838,8 @@
 	    ("critical_exit: td_critnest == 0"));
 	if (td->td_critnest == 1) {
 #ifdef PREEMPTION
-		if (td->td_flags & TDF_OWEPREEMPT) {
+		mtx_assert(&sched_lock, MA_NOTOWNED);
+		if (td->td_pflags & TDP_OWEPREEMPT) {
 			mtx_lock_spin(&sched_lock);
 			mi_switch(SW_INVOL, NULL);
 			mtx_unlock_spin(&sched_lock);
@@ -1872,7 +1873,9 @@
 	 * The new thread should not preempt the current thread if any of the
 	 * following conditions are true:
 	 *
-	 *  - The current thread has a higher (numerically lower) priority.
+	 *  - The current thread has a higher (numerically lower) or
+	 *    equivalent priority.  Note that this prevents curthread from
+	 *    trying to preempt to itself.
 	 *  - It is too early in the boot for context switches (cold is set).
 	 *  - The current thread has an inhibitor set or is in the process of
 	 *    exiting.  In this case, the current thread is about to switch
@@ -1902,7 +1905,7 @@
 	if (ctd->td_critnest > 1) {
 		CTR1(KTR_PROC, "maybe_preempt: in critical section %d",
 		    ctd->td_critnest);
-		ctd->td_flags |= TDF_OWEPREEMPT;
+		ctd->td_pflags |= TDP_OWEPREEMPT;
 		return (0);
 	}
 

==== //depot/projects/nsched/sys/kern/sched_ule.c#15 (text+ko) ====

@@ -2780,7 +2780,8 @@
 	    ("critical_exit: td_critnest == 0"));
 	if (td->td_critnest == 1) {
 #ifdef PREEMPTION
-		if (td->td_flags & TDF_OWEPREEMPT) {
+		mtx_assert(&sched_lock, MA_NOTOWNED);
+		if (td->td_pflags & TDP_OWEPREEMPT) {
 			mtx_lock_spin(&sched_lock);
 			mi_switch(SW_INVOL, NULL);
 			mtx_unlock_spin(&sched_lock);
@@ -2815,7 +2816,9 @@
 	 * The new thread should not preempt the current thread if any of the
 	 * following conditions are true:
 	 *
-	 *  - The current thread has a higher (numerically lower) priority.
+	 *  - The current thread has a higher (numerically lower) or
+	 *    equivalent priority.  Note that this prevents curthread from
+	 *    trying to preempt to itself.
 	 *  - It is too early in the boot for context switches (cold is set).
 	 *  - The current thread has an inhibitor set or is in the process of
 	 *    exiting.  In this case, the current thread is about to switch
@@ -2845,7 +2848,7 @@
 	if (ctd->td_critnest > 1) {
 		CTR1(KTR_PROC, "maybe_preempt: in critical section %d",
 		    ctd->td_critnest);
-		ctd->td_flags |= TDF_OWEPREEMPT;
+		ctd->td_pflags |= TDP_OWEPREEMPT;
 		return (0);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407190112.i6J1Cr1U010556>