Deleted Added
full compact
thr_sig.c (177337) thr_sig.c (178647)
1/*
2 * Copyright (c) 2005, David Xu <davidxu@freebsd.org>
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

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

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 2005, David Xu <davidxu@freebsd.org>
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

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

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libthr/thread/thr_sig.c 177337 2008-03-18 02:06:51Z davidxu $
26 * $FreeBSD: head/lib/libthr/thread/thr_sig.c 178647 2008-04-29 03:58:18Z davidxu $
27 */
28
29#include "namespace.h"
30#include <sys/param.h>
31#include <sys/types.h>
32#include <sys/signalvar.h>
33#include <signal.h>
34#include <errno.h>

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

84 == THR_FLAGS_NEED_SUSPEND))
85 _thr_suspend_check(curthread);
86 }
87}
88
89void
90_thr_suspend_check(struct pthread *curthread)
91{
27 */
28
29#include "namespace.h"
30#include <sys/param.h>
31#include <sys/types.h>
32#include <sys/signalvar.h>
33#include <signal.h>
34#include <errno.h>

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

84 == THR_FLAGS_NEED_SUSPEND))
85 _thr_suspend_check(curthread);
86 }
87}
88
89void
90_thr_suspend_check(struct pthread *curthread)
91{
92 long cycle;
92 uint32_t cycle;
93 int err;
94
95 if (curthread->force_exit)
96 return;
97
98 err = errno;
99 /*
100 * Blocks SIGCANCEL which other threads must send.

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

109 curthread->critical_count++;
110 THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
111 while ((curthread->flags & (THR_FLAGS_NEED_SUSPEND |
112 THR_FLAGS_SUSPENDED)) == THR_FLAGS_NEED_SUSPEND) {
113 curthread->cycle++;
114 cycle = curthread->cycle;
115
116 /* Wake the thread suspending us. */
93 int err;
94
95 if (curthread->force_exit)
96 return;
97
98 err = errno;
99 /*
100 * Blocks SIGCANCEL which other threads must send.

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

109 curthread->critical_count++;
110 THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
111 while ((curthread->flags & (THR_FLAGS_NEED_SUSPEND |
112 THR_FLAGS_SUSPENDED)) == THR_FLAGS_NEED_SUSPEND) {
113 curthread->cycle++;
114 cycle = curthread->cycle;
115
116 /* Wake the thread suspending us. */
117 _thr_umtx_wake(&curthread->cycle, INT_MAX);
117 _thr_umtx_wake(&curthread->cycle, INT_MAX, 0);
118
119 /*
120 * if we are from pthread_exit, we don't want to
121 * suspend, just go and die.
122 */
123 if (curthread->state == PS_DEAD)
124 break;
125 curthread->flags |= THR_FLAGS_SUSPENDED;
126 THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
118
119 /*
120 * if we are from pthread_exit, we don't want to
121 * suspend, just go and die.
122 */
123 if (curthread->state == PS_DEAD)
124 break;
125 curthread->flags |= THR_FLAGS_SUSPENDED;
126 THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
127 _thr_umtx_wait(&curthread->cycle, cycle, NULL);
127 _thr_umtx_wait_uint(&curthread->cycle, cycle, NULL, 0);
128 THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
129 curthread->flags &= ~THR_FLAGS_SUSPENDED;
130 }
131 THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
132 curthread->critical_count--;
133
134 /*
135 * Unblocks SIGCANCEL, it is possible a new SIGCANCEL is ready and

--- 261 unchanged lines hidden ---
128 THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
129 curthread->flags &= ~THR_FLAGS_SUSPENDED;
130 }
131 THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
132 curthread->critical_count--;
133
134 /*
135 * Unblocks SIGCANCEL, it is possible a new SIGCANCEL is ready and

--- 261 unchanged lines hidden ---