<div dir="ltr">Hi,<div><br></div><div>I think I've managed to narrow it down,. rtems_task_self() is documented as "If called from an interrupt service routine, this directive will return the Id of the interrupted task.",.. however if you run a timer server and your timer is initiated using rtems_timer_server_fire_after(), then rtems_task_self() will always return 'TIME'.</div><div><br></div><div>It does not give the "user" task executing before the 'TIME' task,.. as rtems_timer_fire_after() presumably would.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 9 April 2018 at 18:59, Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Apr 9, 2018 at 11:54 AM, Matthew J Fletcher <span dir="ltr"><<a href="mailto:amimjf@gmail.com" target="_blank">amimjf@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div><span style="font-size:12.8px">Some other operating systems allow a timer be created that will fire the associated routine in that tasks context. In rtems timers are either in the interrupt or the timer task, either way, not in the context of the task that created the timer.</span><br></div><div><span style="font-size:12.8px"><br></span></div></div></blockquote><div><br></div></span><div>FWIW I'm not familiar with an OS that does this.  Happy to see any manuals online. </div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px"></span></div><div><span style="font-size:12.8px">This has caused me some head scratching,. the existing task does something like this...</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">do_bunch_of_stuff()</span></div><div><span style="font-size:12.8px">{</span></div><div><span style="font-size:12.8px">  forever {</span><br></div><div><span style="font-size:12.8px">  rtems_message_queue_receive( r</span><span style="font-size:12.8px">tems_task_self</span><span style="font-size:12.8px"> () -> rtems_id , wait_forever_no_timeout</span><span style="font-size:12.8px"> )</span><br></div><div>  do_something_with_messages_rec<wbr>eived();<br></div><div><span style="font-size:12.8px">  }</span><br></div><div><span style="font-size:12.8px">}</span></div></div></blockquote><div><br></div></span><div>I am not 100% sure what you are trying to accomplish but message queues are independent </div><div>objects that tasks/threads block on. You don't pass in the thread id. Message queues have</div><div>their own id returned by the rtems_message_queue_create() call.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">while another task does,..</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">rtems_timer_create(5_seconds, 

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">do_bunch_of_stuff() );</span></span></div><div><span style="font-size:12.8px"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">rtems_message_queue_send( do_bunch_task -> rtems_id, blob1 ); </span><br></span>



<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">rtems_message_queue_send(

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">do_bunch_task -> rtems_id, blob2</span> ); </span> </div><div>

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">rtems_message_queue_send(

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">do_bunch_task -> rtems_id, blob3</span> ); </span> </div><div><span style="font-size:12.8px">// etc</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">of course when do_bunch_of_stuff() gets invoked by the timer, rtems_task_self() is not going to magically know the task id to return.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Whats the best way to deal with this ?, any method i use (events / semaphores, etc) is not going to work because there is already an existing "wait_forever" blocking action,.. i presume i would have to change that to non-blocking then sample the queue every N ?</span></div><span class="m_-450769616782361034HOEnZb"><font color="#888888"><div> 
 
 
 
<br clear="all"><div><br></div>-- <br><div class="m_-450769616782361034m_6556035327525247164m_2500381759770363453gmail_signature"><div><br>regards</div><div>---</div><div>Matthew J Fletcher</div><br></div>
</div></font></span></div>
<br></span>______________________________<wbr>_________________<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<wbr>/listinfo/users</a><br></blockquote></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div><br>regards</div><div>---</div><div>Matthew J Fletcher</div><br></div>
</div>