<div dir="ltr"><div><div>Hi Kim,<br><br></div>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<br> <br></div> for(;;)<br> { <br> ...<br> ...<br> _ISR_Enable( level );<br> /* An ISR could occur here */<br><br> _Thread_Enable_dispatch();<br> /* Another thread could get dispatched here */<br><br> /* Reenter the critical sections so we can attempt the lock again. */<br> _Thread_Disable_dispatch();<br><br> _ISR_Disable( level );<br> }<br><div><br><div class="gmail_extra"> So while waiting it gives up the processor periodically if lock is not available. Hope this helps.<br><br clear="all"></div><div class="gmail_extra"><div><div><div dir="ltr">Thanks,<div><br></div><div>Saurabh Gadia</div></div></div></div>
<br><div class="gmail_quote">On Fri, Aug 21, 2015 at 11:18 PM, Chan Kim <span dir="ltr"><<a href="mailto:ckim@etri.re.kr" target="_blank">ckim@etri.re.kr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
This is a very basic question and I guess something's wrong in my understanding.<br>
I'm trying to use spinlock but not sure if it's working as I intend to use it for.<br>
The _CORE_spinlock_Wait function seems to be disabling interrupt. the code brief say even task dispatch is disabled.<br>
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?<br>
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..)<br>
I'm uinsg version 4.10.99.<br>
Chan<br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a><br>
</blockquote></div><br></div></div></div>