<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Can a RTX task mail itself?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/26696/can-a-rtx-task-mail-itself</link><description> 
Is it possible to for a task to send mail to itself? 

 
example: 

 
/* Wait for mail (actions) to arrive from other tasks */
WaitResult = os_mbx_wait(gsm_mailbox, (VOID**)&amp;amp;gsm_actionP, MS_TO_SYS_TICKS(GSM_TICK_PERIOD) ); /* Wait for the message to</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Can a RTX task mail itself?</title><link>https://community.arm.com/thread/90828?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2011 02:07:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a3049549-cbbc-4524-8f9b-f29c2c410e2b</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Why mail yourself? If you get a timeout, then its because the mail
box is empty. And if you mail yourself when the mail box is empty,
then it will contain a single mail - yours. So when you look for
mails you will directly get your mail, and directly after look for
mails again and get stuck waiting on an empty mb.&lt;/p&gt;

&lt;p&gt;
And if there is all the time mails in the mailbox from other
threads, then you will never get a timeout, so will never add your
mail to yourself. So you will not activate what event you intended to
trig with your own mail.&lt;/p&gt;

&lt;p&gt;
What is the actual problem you are trying to solve? A kind of
round-robin scheduling of other actions?&lt;/p&gt;

&lt;p&gt;
A mail consumer normally solves its own problems either at the
timeout time, or before deciding to look for more mails, so I&amp;#39;m very
much confused about your design plans.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can a RTX task mail itself?</title><link>https://community.arm.com/thread/59120?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2011 01:58:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:677a5936-648b-445d-af4a-5aa29416b631</guid><dc:creator>Johan Moraal</dc:creator><description>&lt;p&gt;&lt;p&gt;
nevermind, this seems to work:&lt;/p&gt;

&lt;pre&gt;
__task void mailMyself (void)
{
        void *msg;
        OS_RESULT waitresult;
        os_mbx_init (mailbox1, sizeof(mailbox1));

        for (;;)
        {
                waitresult = os_mbx_wait (mailbox1, &amp;amp;msg, 10);
                if (waitresult == OS_R_TMO)
                {

                        msg = (void*)malloc(2);
                        os_mbx_send (mailbox1, msg, 0xFFFF);
        }
                else if( (waitresult == OS_R_OK) ||  (waitresult == OS_R_MBX) )
                {
                        free (msg);
                }
                else
                {
                        for(;;);
                }
        }
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>