<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><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_<wbr>received();<br></div><div><span style="font-size:12.8px">  }</span><br></div><div><span style="font-size:12.8px">}</span></div><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><div> 
 
 
 
<br clear="all"><div><br></div>-- <br><div class="m_2500381759770363453gmail_signature"><div><br>regards</div><div>---</div><div>Matthew J Fletcher</div><br></div>
</div></div>