Spin locks

Vardhan, Sundara (GE Infra, Energy) sundara.vardhan@ge.com
Thu Nov 6 15:18:00 GMT 2008


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.



More information about the Gcc-help mailing list