summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread/uthread_resume_np.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc_r/uthread/uthread_resume_np.c')
-rw-r--r--lib/libc_r/uthread/uthread_resume_np.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/lib/libc_r/uthread/uthread_resume_np.c b/lib/libc_r/uthread/uthread_resume_np.c
index 934df58..7c5f46a 100644
--- a/lib/libc_r/uthread/uthread_resume_np.c
+++ b/lib/libc_r/uthread/uthread_resume_np.c
@@ -35,36 +35,20 @@
#include <pthread.h>
#include "pthread_private.h"
+/* Resume a thread: */
int
pthread_resume_np(pthread_t thread)
{
- int ret = -1;
- pthread_t pthread;
- /*
- * Search for the thread in the linked list.
- */
- for (pthread = _thread_link_list; pthread != NULL && ret == -1; pthread = pthread->nxt) {
- /* Is this the thread? */
- if (pthread == thread) {
- /* Found the thread. Is it suspended? */
- if (pthread->state == PS_SUSPENDED) {
- /* Allow the thread to run. */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- ret = 0;
- } else if (pthread->state == PS_RUNNING) {
- /* Thread is already running. */
- ret = 0;
- } else {
- /* Thread is in some other state. */
- errno = EINVAL;
- }
+ int ret;
+
+ /* Find the thread in the list of active threads: */
+ if ((ret = _find_thread(thread)) == 0) {
+ /* The thread exists. Is it suspended? */
+ if (thread->state != PS_SUSPENDED) {
+ /* Allow the thread to run. */
+ PTHREAD_NEW_STATE(thread,PS_RUNNING);
}
}
- /* Check if thread was not found. */
- if (ret == -1) {
- /* No such thread */
- errno = ESRCH;
- }
return(ret);
}
#endif
OpenPOWER on IntegriCloud