core spinlock wait returns immediately

Andrei Dimitrief-Jianu andrei.dimitrief.jianu at
Thu Oct 11 20:46:12 UTC 2012

On Thu, Oct 11, 2012 at 9:58 AM, Gedare Bloom <gedare at> wrote:
> Is the spinlock already locked? if not it would return immediately
> Did the thread that's attempting to gain the lock previuosly lock it?
> if so it would return immediately
> -Gedare
> On Wed, Oct 10, 2012 at 11:59 PM, Andrei Dimitrief-Jianu
> <andrei.dimitrief.jianu at> wrote:
>> Hello,
>> I initialize a core spinlock using the code below:
>>   CORE_spinlock_Attributes spinlock_attributes;
>>   spinlock_attributes.XXX = 0;
>>   _CORE_spinlock_Initialize( &spinlock, &spinlock_attributes );
>> When calling wait() on the same spinlock from a worker task using the
>> code below, the task returns w/o waiting for the spinlock to be
>> released.
>>   CORE_spinlock_Status spinlock_status;
>>   spinlock_status = _CORE_spinlock_Wait( &spinlock, true, 0 );
>> Anything that is obvious that I am doing wrong?
>> Thanks!
>> _______________________________________________
>> rtems-devel mailing list
>> rtems-devel at

I need to have a worker task waiting on the spinlock until
the main task is releasing the lock or the spinlock times out.

The CORE_spinlock exposes 3 functions:

void _CORE_spinlock_Initialize(
  CORE_spinlock_Control       *the_spinlock,
  CORE_spinlock_Attributes    *the_spinlock_attributes

CORE_spinlock_Status _CORE_spinlock_Wait(
  CORE_spinlock_Control  *the_spinlock,
  bool                    wait,
  Watchdog_Interval       timeout

CORE_spinlock_Status _CORE_spinlock_Release(
  CORE_spinlock_Control *the_spinlock

I am assuming that I can initialize the spinlock as locked or
as attributes to _CORE_spinlock_Initialize().

Once the spinlock is initialized as locked by the main task, I can
call _CORE_spinlock_Wait() from the worker task to block until
_CORE_spinlock_Release() is called by the main task or the call times out.

The problem that I have is that the worker task does not block. I am not
sure that the approach described above is the right one.


More information about the devel mailing list