thr_resume_np.c (113661) | thr_resume_np.c (114664) |
---|---|
1/* 2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/lib/libkse/thread/thr_resume_np.c 113661 2003-04-18 07:09:43Z deischen $ | 32 * $FreeBSD: head/lib/libkse/thread/thr_resume_np.c 114664 2003-05-04 16:17:01Z deischen $ |
33 */ 34#include <errno.h> 35#include <pthread.h> 36#include "thr_private.h" 37 38static void resume_common(struct pthread *); 39 40__weak_reference(_pthread_resume_np, pthread_resume_np); --- 4 unchanged lines hidden (view full) --- 45int 46_pthread_resume_np(pthread_t thread) 47{ 48 struct pthread *curthread = _get_curthread(); 49 int ret; 50 51 /* Add a reference to the thread: */ 52 if ((ret = _thr_ref_add(curthread, thread, /*include dead*/0)) == 0) { | 33 */ 34#include <errno.h> 35#include <pthread.h> 36#include "thr_private.h" 37 38static void resume_common(struct pthread *); 39 40__weak_reference(_pthread_resume_np, pthread_resume_np); --- 4 unchanged lines hidden (view full) --- 45int 46_pthread_resume_np(pthread_t thread) 47{ 48 struct pthread *curthread = _get_curthread(); 49 int ret; 50 51 /* Add a reference to the thread: */ 52 if ((ret = _thr_ref_add(curthread, thread, /*include dead*/0)) == 0) { |
53 /* Is it currently suspended? */ 54 if ((thread->flags & THR_FLAGS_SUSPENDED) != 0) { 55 /* Lock the threads scheduling queue: */ 56 THR_SCHED_LOCK(curthread, thread); 57 58 if ((curthread->state != PS_DEAD) && 59 (curthread->state != PS_DEADLOCK) && 60 ((curthread->flags & THR_FLAGS_EXITING) != 0)) 61 resume_common(thread); 62 63 /* Unlock the threads scheduling queue: */ 64 THR_SCHED_UNLOCK(curthread, thread); 65 } | 53 /* Lock the threads scheduling queue: */ 54 THR_SCHED_LOCK(curthread, thread); 55 resume_common(thread); 56 THR_SCHED_UNLOCK(curthread, thread); |
66 _thr_ref_delete(curthread, thread); 67 } 68 return (ret); 69} 70 71void 72_pthread_resume_all_np(void) 73{ 74 struct pthread *curthread = _get_curthread(); 75 struct pthread *thread; 76 kse_critical_t crit; 77 78 /* Take the thread list lock: */ 79 crit = _kse_critical_enter(); 80 KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock); 81 82 TAILQ_FOREACH(thread, &_thread_list, tle) { | 57 _thr_ref_delete(curthread, thread); 58 } 59 return (ret); 60} 61 62void 63_pthread_resume_all_np(void) 64{ 65 struct pthread *curthread = _get_curthread(); 66 struct pthread *thread; 67 kse_critical_t crit; 68 69 /* Take the thread list lock: */ 70 crit = _kse_critical_enter(); 71 KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock); 72 73 TAILQ_FOREACH(thread, &_thread_list, tle) { |
83 if ((thread != curthread) && 84 ((thread->flags & THR_FLAGS_SUSPENDED) != 0) && 85 (thread->state != PS_DEAD) && 86 (thread->state != PS_DEADLOCK) && 87 ((thread->flags & THR_FLAGS_EXITING) == 0)) { | 74 if (thread != curthread) { |
88 THR_SCHED_LOCK(curthread, thread); 89 resume_common(thread); 90 THR_SCHED_UNLOCK(curthread, thread); 91 } 92 } 93 94 /* Release the thread list lock: */ 95 KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock); --- 17 unchanged lines hidden --- | 75 THR_SCHED_LOCK(curthread, thread); 76 resume_common(thread); 77 THR_SCHED_UNLOCK(curthread, thread); 78 } 79 } 80 81 /* Release the thread list lock: */ 82 KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock); --- 17 unchanged lines hidden --- |