Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jun 2002 23:49:44 -0700 (PDT)
From:      Julian Elischer <julian@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 12640 for review
Message-ID:  <200206100649.g5A6niM20387@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=12640

Change 12640 by julian@julian_jules1 on 2002/06/09 23:48:50

	slight cleanup of KSE singlethreading.

Affected files ...

... //depot/projects/kse/sys/kern/kern_thread.c#57 edit

Differences ...

==== //depot/projects/kse/sys/kern/kern_thread.c#57 (text+ko) ====

@@ -446,7 +446,9 @@
 		 * Wake us up when everyone else has suspended.
 		 * (or died)
 		 */
+		TAILQ_INSERT_TAIL(&p->p_suspended, td, td_runq);
 		td->td_state = TDS_SUSPENDED;
+		p->p_suspcount++;
 		mtx_lock_spin(&sched_lock);
 		mtx_unlock(&Giant);
 		PROC_UNLOCK(p);
@@ -517,8 +519,13 @@
 					mtx_unlock(&Giant);
 				thread_exit();
 			}
-			/* One for us and one for the single waiter. */
-			if (p->p_numthreads == (p->p_suspcount + 2)) {
+			/*
+			 * Just an optimised version of thread_unsuspend().
+			 */
+			if (p->p_numthreads == (p->p_suspcount + 1)) {
+				TAILQ_REMOVE(&p->p_suspended,
+				    p->p_singlethread, td_runq);
+				p->p_suspcount--;
 				setrunqueue(p->p_singlethread);
 				p->p_singlethread = NULL;
 			}
@@ -563,7 +570,9 @@
 			setrunqueue(td);
 		}
 	} else if ((P_SHOULDSTOP(p) == P_STOPPED_SNGL) &&
-	    (p->p_numthreads == (p->p_suspcount + 1))) {
+	    (p->p_numthreads == p->p_suspcount)) {
+		TAILQ_REMOVE(&p->p_suspended, p->p_singlethread, td_runq);
+		p->p_suspcount--;
 		/*
 		 * Stopping everything also did the job for the single
 		 * threading request. Now we've downgraded to single-threaded,
@@ -583,7 +592,7 @@
 	td = curthread;
 	p = td->td_proc;
 	PROC_LOCK_ASSERT(p, MA_OWNED);
-	p->p_flag &= P_STOPPED_SNGL;
+	p->p_flag &= ~P_STOPPED_SNGL;
 	thread_unsuspend(p);
 }
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




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