deadlock from spinlock waiting..

Saurabh Gadia gadia at usc.edu
Sat Aug 22 14:56:05 UTC 2015


Hi Kim,

As per your case task A has the lock and task B will be waiting for the
lock. Firstly as per your contex, I take that you are running querying
about uniprocessor targets. So in CORE_spinlock_Wait routine if the lock is
not available and if provide no timeout for this routing then its true that
this thread will spin indefinitely until it gets the lock. But main
question how will it get lock if it disables dispatches and interrupts. I
guess your going in right direction. But while waiting for the lock it
performs following things: from corespinlockwait.c

        for(;;)
        {
            ...
            ...
           _ISR_Enable( level );
       /* An ISR could occur here */

       _Thread_Enable_dispatch();
       /* Another thread could get dispatched here */

       /* Reenter the critical sections so we can attempt the lock again. */
       _Thread_Disable_dispatch();

       _ISR_Disable( level );
        }

  So while waiting it gives up the processor periodically if lock is not
available. Hope this helps.

Thanks,

Saurabh Gadia

On Fri, Aug 21, 2015 at 11:18 PM, Chan Kim <ckim at etri.re.kr> wrote:

> Hello,
> This is a very basic question and I guess something's wrong in my
> understanding.
> I'm trying to use spinlock but not sure if it's working as I intend to use
> it for.
> The _CORE_spinlock_Wait function seems to be disabling interrupt. the code
> brief say even task dispatch is disabled.
> Then when task A already has the lock, and task B tries to get the lock,
> how can task A release it if it is not dispatched?
> My case right now seems like that. (write task waiting for the lock, but
> read task has the lock and because interrupt is disabled,  read task cannot
> process things..)
> I'm uinsg version 4.10.99.
> Chan
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20150822/912aa1e4/attachment-0002.html>


More information about the users mailing list