PERFORCE change 65518 for review

David Xu davidxu at FreeBSD.org
Fri Nov 19 20:53:22 PST 2004


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

Change 65518 by davidxu at davidxu_alona on 2004/11/20 04:52:19

	Use thread lock. there should be thr_suspend_thread,
	thr_resume_thread to suspend or resume thread directly
	on kernel, will introduce it later.

Affected files ...

.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_resume_np.c#2 edit

Differences ...

==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_resume_np.c#2 (text+ko) ====

@@ -35,7 +35,7 @@
 #include <pthread.h>
 #include "thr_private.h"
 
-static struct kse_mailbox *resume_common(struct pthread *);
+static long resume_common(struct pthread *);
 
 __weak_reference(_pthread_resume_np, pthread_resume_np);
 __weak_reference(_pthread_resume_all_np, pthread_resume_all_np);
@@ -46,18 +46,18 @@
 _pthread_resume_np(pthread_t thread)
 {
 	struct pthread *curthread = _get_curthread();
-	struct kse_mailbox *kmbx;
+	long tid = -1;
 	int ret;
 
 	/* Add a reference to the thread: */
 	if ((ret = _thr_ref_add(curthread, thread, /*include dead*/0)) == 0) {
 		/* Lock the threads scheduling queue: */
-		THR_SCHED_LOCK(curthread, thread);
-		kmbx = resume_common(thread);
-		THR_SCHED_UNLOCK(curthread, thread);
+		THR_THREAD_LOCK(curthread, thread);
+		tid = resume_common(thread);
+		THR_THREAD_UNLOCK(curthread, thread);
 		_thr_ref_delete(curthread, thread);
-		if (kmbx != NULL)
-			kse_wakeup(kmbx);
+		if (tid !=-1)
+			thr_wake(tid);
 	}
 	return (ret);
 }
@@ -67,29 +67,26 @@
 {
 	struct pthread *curthread = _get_curthread();
 	struct pthread *thread;
-	struct kse_mailbox *kmbx;
-	kse_critical_t crit;
+	long tid;
 
 	/* Take the thread list lock: */
-	crit = _kse_critical_enter();
-	KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock);
+	THR_LOCK_ACQUIRE(curthread, &_thread_list_lock);
 
 	TAILQ_FOREACH(thread, &_thread_list, tle) {
 		if (thread != curthread) {
-			THR_SCHED_LOCK(curthread, thread);
-			kmbx = resume_common(thread);
-			THR_SCHED_UNLOCK(curthread, thread);
-			if (kmbx != NULL)
-				kse_wakeup(kmbx);
+			THR_THREAD_LOCK(curthread, thread);
+			tid = resume_common(thread);
+			THR_THREAD_UNLOCK(curthread, thread);
+			if (tid != -1)
+				thr_wake(tid);
 		}
 	}
 
 	/* Release the thread list lock: */
-	KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock);
-	_kse_critical_leave(crit);
+	THR_LOCK_RELEASE(curthread, &_thread_list_lock);
 }
 
-static struct kse_mailbox *
+static long
 resume_common(struct pthread *thread)
 {
 	/* Clear the suspend flag: */
@@ -103,5 +100,5 @@
 	if (thread->state == PS_SUSPENDED)
 		return (_thr_setrunnable_unlocked(thread));
 	else
-		return (NULL);
+		return (-1);
 }


More information about the p4-projects mailing list