core spinlock wait returns immediately

Joel Sherrill joel.sherrill at OARcorp.com
Thu Oct 11 22:37:40 UTC 2012


On 10/11/2012 04:56 PM, Gedare Bloom wrote:
> Are you doing this at user-level? I don't think core spinlock part of
> the public API...
It is promoted out through pthread_spin*

There are tests for it. If it isn't behaving right, then the
tests are malformed.

Post a complete and simple test case and we can look at
it.
> I haven't looked closely at the code to tell if it supports using the
> attributes the way you suggest, so I don't know the answer to your
> question.
>
> -Gedare
>
> On Thu, Oct 11, 2012 at 4:46 PM, Andrei Dimitrief-Jianu
> <andrei.dimitrief.jianu at gmail.com>  wrote:
>> On Thu, Oct 11, 2012 at 9:58 AM, Gedare Bloom<gedare at rtems.org>  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 gmail.com>  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 rtems.org
>>>> http://www.rtems.org/mailman/listinfo/rtems-devel
>>
>> 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
>> unlocked by passing CORE_SPINLOCK_LOCKED or CORE_SPINLOCK_UNLOCKED
>> 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.
>>
>> Thanks!
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel


-- 
Joel Sherrill, Ph.D.             Director of Research&  Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35806
Support Available               (256) 722-9985




More information about the devel mailing list