Deleted Added
full compact
thr_pspinlock.c (157457) thr_pspinlock.c (161068)
1/*-
2 * Copyright (c) 2003 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 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2003 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 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libthr/thread/thr_pspinlock.c 157457 2006-04-04 02:57:49Z davidxu $
26 * $FreeBSD: head/lib/libthr/thread/thr_pspinlock.c 161068 2006-08-08 04:42:41Z davidxu $
27 */
28
29#include "namespace.h"
30#include <errno.h>
31#include <stdlib.h>
32#include <pthread.h>
33#include "un-namespace.h"
34

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

99 int ret, count;
100
101 if (lock == NULL || (lck = *lock) == NULL)
102 ret = EINVAL;
103 else {
104 count = SPIN_COUNT;
105 while ((ret = THR_UMTX_TRYLOCK(curthread, &lck->s_lock)) != 0) {
106 while (lck->s_lock) {
27 */
28
29#include "namespace.h"
30#include <errno.h>
31#include <stdlib.h>
32#include <pthread.h>
33#include "un-namespace.h"
34

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

99 int ret, count;
100
101 if (lock == NULL || (lck = *lock) == NULL)
102 ret = EINVAL;
103 else {
104 count = SPIN_COUNT;
105 while ((ret = THR_UMTX_TRYLOCK(curthread, &lck->s_lock)) != 0) {
106 while (lck->s_lock) {
107#ifdef __i386__
108 /* tell cpu we are spinning */
109 __asm __volatile("pause");
110#endif
111 if (--count <= 0) {
112 count = SPIN_COUNT;
107 if (_thr_smp_cpus <= 1) {
113 _pthread_yield();
108 _pthread_yield();
109 } else {
110#if defined(__i386__) || defined(__x86_64__)
111 /* tell cpu we are spinning */
112 __asm __volatile("pause");
113#endif
114 if (--count <= 0) {
115 count = SPIN_COUNT;
116 _pthread_yield();
117 }
114 }
115 }
116 }
117 ret = 0;
118 }
119
120 return (ret);
121}

--- 15 unchanged lines hidden ---
118 }
119 }
120 }
121 ret = 0;
122 }
123
124 return (ret);
125}

--- 15 unchanged lines hidden ---