Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jan 2005 17:47:18 -0500
From:      John Baldwin <jhb@FreeBSD.org>
To:        David Xu <davidxu@FreeBSD.org>
Cc:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   Re: PERFORCE change 68252 for review
Message-ID:  <200501051747.18388.jhb@FreeBSD.org>
In-Reply-To: <200501041314.j04DEVE3017245@repoman.freebsd.org>
References:  <200501041314.j04DEVE3017245@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 04 January 2005 08:14 am, David Xu wrote:
> http://perforce.freebsd.org/chv.cgi?CH=68252
>
> Change 68252 by davidxu@davidxu_tiger on 2005/01/04 13:14:06
>
> 	insert "pause" instructor for  i386.
> 	style fix.

You can use 'cpu_spinwait()' for this to be MI.

> Affected files ...
>
> ..
> //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_pspinlock.c#7
> edit
>
> Differences ...
>
> ====
> //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_pspinlock.c#7
> (text+ko) ====
>
> @@ -100,6 +100,10 @@
>  	else {
>  		count = SPIN_COUNT;
>  		while ((ret = umtx_trylock(&lck->s_lock, self->tid)) != 0) {
> +#ifdef __i386__
> +			/* tell cpu we are spinning */
> +			__asm __volatile("pause");
> +#endif
>  			if (--count <= 0) {
>  				count = SPIN_COUNT;
>  				_pthread_yield();
> @@ -120,7 +124,7 @@
>  	if (lock == NULL || (lck = *lock) == NULL)
>  		ret = EINVAL;
>  	else {
> -		ret =umtx_unlock(&lck->s_lock, self->tid);
> +		ret = umtx_unlock(&lck->s_lock, self->tid);
>  	}
>  	return (ret);
>  }

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200501051747.18388.jhb>