From 9ba1f9fa381dcbfb861533fdda13f9f27da78f14 Mon Sep 17 00:00:00 2001 From: deischen Date: Fri, 24 May 2002 04:32:28 +0000 Subject: Revamp suspend and resume. While I'm here add pthread_suspend_all_np() and pthread_resume_all_np(). These suspend and resume all threads except the current thread, respectively. The existing functions pthread_single_np() and pthread_multi_np(), which formerly had no effect, now exhibit the same behaviour and pthread_suspend_all_np() and pthread_resume_all_np(). These functions have been added mostly for the native java port. Don't allow the uthread kernel pipe to use the same descriptors as stdio. Mostily submitted by Oswald Buddenhagen . Correct some minor style nits. --- lib/libpthread/thread/thr_mutex.c | 50 +++++++-------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) (limited to 'lib/libpthread/thread/thr_mutex.c') diff --git a/lib/libpthread/thread/thr_mutex.c b/lib/libpthread/thread/thr_mutex.c index 0f67b4b..86e0b8b 100644 --- a/lib/libpthread/thread/thr_mutex.c +++ b/lib/libpthread/thread/thr_mutex.c @@ -887,21 +887,9 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) */ if (((*mutex)->m_owner = mutex_queue_deq(*mutex)) != NULL) { - /* - * Unless the new owner of the mutex is - * currently suspended, allow the owner - * to run. If the thread is suspended, - * make a note that the thread isn't in - * a wait queue any more. - */ - if (((*mutex)->m_owner->state != - PS_SUSPENDED)) { - PTHREAD_NEW_STATE((*mutex)->m_owner, - PS_RUNNING); - } else { - (*mutex)->m_owner->suspended = - SUSP_NOWAIT; - } + /* Make the new owner runnable: */ + PTHREAD_NEW_STATE((*mutex)->m_owner, + PS_RUNNING); /* * Add the mutex to the threads list of @@ -1019,20 +1007,10 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) (*mutex)->m_prio; /* - * Unless the new owner of the mutex is - * currently suspended, allow the owner - * to run. If the thread is suspended, - * make a note that the thread isn't in - * a wait queue any more. + * Make the new owner runnable: */ - if (((*mutex)->m_owner->state != - PS_SUSPENDED)) { - PTHREAD_NEW_STATE((*mutex)->m_owner, - PS_RUNNING); - } else { - (*mutex)->m_owner->suspended = - SUSP_NOWAIT; - } + PTHREAD_NEW_STATE((*mutex)->m_owner, + PS_RUNNING); } } break; @@ -1148,20 +1126,10 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) (*mutex)->m_prio; /* - * Unless the new owner of the mutex is - * currently suspended, allow the owner - * to run. If the thread is suspended, - * make a note that the thread isn't in - * a wait queue any more. + * Make the new owner runnable: */ - if (((*mutex)->m_owner->state != - PS_SUSPENDED)) { - PTHREAD_NEW_STATE((*mutex)->m_owner, - PS_RUNNING); - } else { - (*mutex)->m_owner->suspended = - SUSP_NOWAIT; - } + PTHREAD_NEW_STATE((*mutex)->m_owner, + PS_RUNNING); } } break; -- cgit v1.1