Deleted Added
full compact
thr_join.c (113658) thr_join.c (113661)
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_join.c 113658 2003-04-18 05:04:16Z deischen $
32 * $FreeBSD: head/lib/libkse/thread/thr_join.c 113661 2003-04-18 07:09:43Z deischen $
33 */
34#include <errno.h>
35#include <pthread.h>
36#include "thr_private.h"
37
38__weak_reference(_pthread_join, pthread_join);
39
40int
41_pthread_join(pthread_t pthread, void **thread_return)
42{
33 */
34#include <errno.h>
35#include <pthread.h>
36#include "thr_private.h"
37
38__weak_reference(_pthread_join, pthread_join);
39
40int
41_pthread_join(pthread_t pthread, void **thread_return)
42{
43 struct pthread *curthread = _get_curthread();
44 int ret = 0;
43 struct pthread *curthread = _get_curthread();
44 kse_critical_t crit;
45 int ret = 0;
45
46 _thr_enter_cancellation_point(curthread);
47
48 /* Check if the caller has specified an invalid thread: */
49 if (pthread == NULL || pthread->magic != THR_MAGIC) {
50 /* Invalid thread: */
51 _thr_leave_cancellation_point(curthread);
52 return (EINVAL);

--- 25 unchanged lines hidden (view full) ---

78 /* Lock the target thread while checking its state. */
79 THR_SCHED_LOCK(curthread, pthread);
80 if ((pthread->state == PS_DEAD) ||
81 ((pthread->flags & THR_FLAGS_EXITING) != 0)) {
82 if (thread_return != NULL)
83 /* Return the thread's return value: */
84 *thread_return = pthread->ret;
85
46
47 _thr_enter_cancellation_point(curthread);
48
49 /* Check if the caller has specified an invalid thread: */
50 if (pthread == NULL || pthread->magic != THR_MAGIC) {
51 /* Invalid thread: */
52 _thr_leave_cancellation_point(curthread);
53 return (EINVAL);

--- 25 unchanged lines hidden (view full) ---

79 /* Lock the target thread while checking its state. */
80 THR_SCHED_LOCK(curthread, pthread);
81 if ((pthread->state == PS_DEAD) ||
82 ((pthread->flags & THR_FLAGS_EXITING) != 0)) {
83 if (thread_return != NULL)
84 /* Return the thread's return value: */
85 *thread_return = pthread->ret;
86
86 /* Unlock the thread and remove the reference. */
87 /* Detach the thread. */
88 pthread->attr.flags |= PTHREAD_DETACHED;
89
90 /* Unlock the thread. */
87 THR_SCHED_UNLOCK(curthread, pthread);
91 THR_SCHED_UNLOCK(curthread, pthread);
92
93 /*
94 * Remove the thread from the list of active
95 * threads and add it to the GC list.
96 */
97 crit = _kse_critical_enter();
98 KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock);
99 THR_LIST_REMOVE(pthread);
100 THR_GCLIST_ADD(pthread);
101 KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock);
102 _kse_critical_leave(crit);
103
104 /* Remove the reference. */
88 _thr_ref_delete(curthread, pthread);
89 }
90 else if (pthread->joiner != NULL) {
91 /* Unlock the thread and remove the reference. */
92 THR_SCHED_UNLOCK(curthread, pthread);
93 _thr_ref_delete(curthread, pthread);
94
95 /* Multiple joiners are not supported. */

--- 37 unchanged lines hidden ---
105 _thr_ref_delete(curthread, pthread);
106 }
107 else if (pthread->joiner != NULL) {
108 /* Unlock the thread and remove the reference. */
109 THR_SCHED_UNLOCK(curthread, pthread);
110 _thr_ref_delete(curthread, pthread);
111
112 /* Multiple joiners are not supported. */

--- 37 unchanged lines hidden ---