PERFORCE change 65488 for review

David Xu davidxu at FreeBSD.org
Fri Nov 19 18:19:00 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=65488

Change 65488 by davidxu at davidxu_alona on 2004/11/20 02:18:27

	if a thread is resumed by thr_wake, it should return 0, 
	for example, a signal can cause ERESTART to be returned,
	this will cause the wakeup to be lost.

Affected files ...

.. //depot/projects/davidxu_thread/src/sys/kern/kern_thr.c#3 edit

Differences ...

==== //depot/projects/davidxu_thread/src/sys/kern/kern_thr.c#3 (text+ko) ====

@@ -270,11 +270,21 @@
 	if ((td->td_flags & TDF_THRWAKEUP) == 0)
 		error = msleep((void *)td, &td->td_proc->p_mtx,
 		    td->td_priority | PCATCH, "lthr", hz);
-	mtx_lock_spin(&sched_lock);
-	td->td_flags &= ~TDF_THRWAKEUP;
-	mtx_unlock_spin(&sched_lock);
+	if (td->td_flags & TDF_THRWAKEUP) {
+		mtx_lock_spin(&sched_lock);
+		td->td_flags &= ~TDF_THRWAKEUP;
+		mtx_unlock_spin(&sched_lock);
+		PROC_UNLOCK(td->td_proc);
+		return (0);
+	}
 	PROC_UNLOCK(td->td_proc);
-	return (error == EWOULDBLOCK ? ETIMEDOUT : error);
+	if (error == EWOULDBLOCK)
+		error = ETIMEDOUT;
+	else if (error == ERESTART) {
+		if (hz != 0)
+			error = EINTR;
+	}
+	return (error);
 }
 
 int


More information about the p4-projects mailing list