<div dir="ltr">Hi,<div><br></div><div>Thanks for the help.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">What is the contradiction? You shouldn't have a blocked thread in a<br>queue when you want to delete it. The thread needs to be in some kind<br>of "quiescent" state.</blockquote><div>Okay, I'll look further into this. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 24, 2021 at 10:19 PM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Feb 24, 2021 at 12:54 AM Richi Dubey <<a href="mailto:richidubey@gmail.com" target="_blank">richidubey@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> Can someone please give a brief overview of what these three lines aim to achieve:<br>
><br>
>   } else if ( _Thread_Is_life_change_allowed( previous ) ) {<br>
>     _Thread_Add_life_change_request( the_thread );<br>
>     _Thread_State_release( the_thread, &lock_context );<br>
><br>
>     _Thread_Finalize_life_change( the_thread, priority );<br>
><br>
> 492 threadrestart.c<br>
><br>
> I am asking because in line 92 of sp02, this _Thread_Cancel function is called, and because of _Thread_Add_life_change_request( the_thread ) ->_Thread_Set_state_locked -> _Scheduler_Block is called and because of _Thread_Finalize_life_change->_Thread_Remove_life_change_request->_Thread_Clear_state_locked->_Scheduler_Unblock is called, which is contradictory.<br>
><br>
What is the contradiction? You shouldn't have a blocked thread in a<br>
queue when you want to delete it. The thread needs to be in some kind<br>
of "quiescent" state.<br>
<br>
Thread cancellation and end-of-life considerations are tricky. Maybe<br>
your scheduler has some invalid assumptions about how threads<br>
terminate?<br>
<br>
The API-level requirements derive from two directions:<br>
<a href="https://docs.rtems.org/branches/master/c-user/scheduling-concepts/background.html#task-state-transitions" rel="noreferrer" target="_blank">https://docs.rtems.org/branches/master/c-user/scheduling-concepts/background.html#task-state-transitions</a><br>
<br>
<a href="https://docs.rtems.org/branches/master/posix-users/thread_cancellation.html" rel="noreferrer" target="_blank">https://docs.rtems.org/branches/master/posix-users/thread_cancellation.html</a><br>
<br>
The low-level detailed implementation is probably not so<br>
well-documented. You might be able to find some clues in the doxygen.<br>
Otherwise you probably have to keep working your way through the code<br>
like you have been.<br>
<br>
> Thanks,<br>
> Richi.<br>
> _______________________________________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>