PERFORCE change 65516 for review
David Xu
davidxu at FreeBSD.org
Fri Nov 19 20:46:12 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=65516
Change 65516 by davidxu at davidxu_alona on 2004/11/20 04:46:00
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_suspend_np.c#2 edit
Differences ...
==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_suspend_np.c#2 (text+ko) ====
@@ -55,10 +55,10 @@
else if ((ret = _thr_ref_add(curthread, thread, /*include dead*/0))
== 0) {
/* Lock the threads scheduling queue: */
- THR_SCHED_LOCK(curthread, thread);
+ THR_THREAD_LOCK(curthread, thread);
suspend_common(thread);
/* Unlock the threads scheduling queue: */
- THR_SCHED_UNLOCK(curthread, thread);
+ THR_THREAD_UNLOCK(curthread, thread);
/* Don't forget to remove the reference: */
_thr_ref_delete(curthread, thread);
@@ -71,23 +71,20 @@
{
struct pthread *curthread = _get_curthread();
struct pthread *thread;
- kse_critical_t crit;
/* 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);
+ THR_THREAD_LOCK(curthread, thread);
suspend_common(thread);
- THR_SCHED_UNLOCK(curthread, thread);
+ THR_THREAD_UNLOCK(curthread, thread);
}
}
/* Release the thread list lock: */
- KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock);
- _kse_critical_leave(crit);
+ THR_LOCK_RELEASE(curthread, &_thread_list_lock);
}
void
@@ -97,13 +94,6 @@
(thread->state != PS_DEADLOCK) &&
((thread->flags & THR_FLAGS_EXITING) == 0)) {
thread->flags |= THR_FLAGS_SUSPENDED;
- if ((thread->flags & THR_FLAGS_IN_RUNQ) != 0) {
- THR_RUNQ_REMOVE(thread);
- THR_SET_STATE(thread, PS_SUSPENDED);
- }
-#ifdef NOT_YET
- if ((thread->attr.flags & PTHREAD_SCOPE_SYSTEM) != 0)
- /* ??? */
-#endif
+ /* XXX how ? */
}
}
More information about the p4-projects
mailing list