This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Spin locks


Hi Dean, Andrew

Thanks for your replies. I will definitely get a test case and send
across soon. I apologize for the half-baked and abrupt request.

With Regards

Vardhan

-----Original Message-----
From: Dean Anderson [mailto:dean@av8.com] 
Sent: Thursday, November 06, 2008 11:31 AM
To: Vardhan, Sundara (GE Infra, Energy)
Cc: Andrew Haley
Subject: RE: Spin locks

Its nice to have code that compiles when you submit examples.  One
presumes the experts being queried know how to write correct code
themselves; what's not clear is what kind of error you've made, or what
kind of error the compiler has made. That's why a test case is
necessary.

In this case, I suspect that you need to spin on
__sync_lock_test_and_set, and make sure that ip is initialized to zero
so that some thread can get the lock.  

http://archives.free.net.ph/message/20080225.121911.0732aa8f.fr.html

		--Dean

On Thu, 6 Nov 2008, Vardhan, Sundara (GE Infra, Energy) wrote:

> Hi Andrew
> 
> Thanks for the reply. Please find below a code snippet of the function

> that calls the spin lock. Hope this helps
> 
> int gstas( unsigned char *ip )
> #else
> int gstas(ip)
> unsigned char *ip;
> #endif
> /*
> PURPOSE: To atomically lock a byte.
> 
> DESCRIPTION: This routine is used to atomically lock a lock structure 
> which is one byte in size.
> 
> */
> {
> unsigned char   gstas_orig_byte ;
> int             status = RT_SUCCESS ;
> 
> gstas_orig_byte=__sync_lock_test_and_set(ip,0xff);
> if ( 0 != gstas_orig_byte )
>     {
>     status = RT_ERROR ;
>     }
> return( status ) ;
> }
> 
> The above function is called by different processes when the product 
> is in runtime. This function returns error in different processes 
> during different run cycles.
> 
> Hope this helps.
> 
> With Regards
> 
> Vardhan
> 
>  
> 
> -----Original Message-----
> From: Andrew Haley [mailto:aph@redhat.com]
> Sent: Thursday, November 06, 2008 10:03 AM
> To: Vardhan, Sundara (GE Infra, Energy)
> Cc: gcc ML
> Subject: Re: Spin locks
> 
> Vardhan, Sundara (GE Infra, Energy) wrote:
> 
> > I compiled my application with gcc4.2.4 and I keep getting spin lock

> > errors. The same application, when compiled with gcc 4.1.1, had no 
> > issues. I am using -march=pentiumpro as compile option as I am using
> > __sync_lock_test_and_set() calls for spin locks. Any reason that
these
> 
> > errors should occur when application is compiled with 4.2.4? I would

> > very much appreciate your help and advice.
> 
> As usual, we really need an example test case to give you any 
> meaningful answers.  I know that producing test cases can be 
> difficult, but it is almost always worthwhile.
> 
> Andrew.
> 
> 

-- 
Av8 Internet   Prepared to pay a premium for better service?
www.av8.net         faster, more reliable, better service
617 344 9000   




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]