This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SWI post before function completes C5510

Hi,

I have this question about the SWI post in C5510.

What does the DSP/BIOS do if my code does another SWI_post to same function before the previous one is complete?

Does the second SWI_post get dropped?  Or does it expect the function to b re-entrant?

 

Thanks,

Regards,

Aditi.

  • The SWI is made to function very similar to a hardware interrupt.  If you call SWI_post a bunch of times in a row (and I'm making an assumption that you are calling from a higher priority thread because otherwise the SWI would run right away and then return before getting posted again) then the SWI will only run one time.

    If you're concerned about that case you can use SWI_inc instead of SWI_post.  It's important to understand that the function still only runs one time, but now inside that function you can call SWI_getmbox() and detect that it has been posted multiple times.  That SWI can then iterate the correct number of times, i.e. you would have a for loop in the SWI function.

  • Brad,

    I just wanted to let you know  that the SWI_post gets called from an ISR.

    Also, it is the same SWI_post function that is posted second time before the

    function in the previous post gets completed. So the priority for the SWI_post is

    the same.

     

    Thanks,

    Aditi.

  • Aditi,

    Have you seen the SWI description in the BIOS User's Guide (http://focus.ti.com/lit/ug/spru423h/spru423h.pdf)?  In particular, sections 4.3.4 and 4.3.5 might clear up some of your questions...

    Regards,
    Scott

  • Brad,

    This is what my scenario is like.

    I have an ISR from where I call the SWI_post to a function.

    The function is taking about 15msec to complete.

    But the SWI_post will again post to the function after 10 msec (i.e before the

    function completes execution). So, do you mean that this second SWI_post will

    be ignored since the function is still busy? 

    Thanks,

    Regards,

    Aditi.

  • Aditi,

    That is incorrect.  The point being made was that multiple calls to Swi_post before the BIOS scheduler starts running the Swi thread will not cause the thread to run multiple times -- it will only cause the scheduler to run the Swi thread once.  The advice about using Swi_inc() was in case your application *cares* how many times the Swi was posted.  If that's not the case for your app, then you don't need to do that.

    For the use-case that you describe in which the Swi is posted and the Swi's function begins executing and then the Swi is posted again while the function is running, that just means the Swi thread will be scheduled to run again after the preceding Swi function completes.

    How quickly the additional Swi function begins to execute will depend on if any other threads of equal or greater priority are ready to run. Any higher priority threads will run first of course.  Any any other Swi threads of the same priority that were posted first will run first, since the BIOS scheduler takes them on a first-in/first-out basis.

    Dave

  • David,

    If the SWI_post function is queued and will run a second time, then that should work for us,

    as long as we are careful with data buffering done in our ISR.

    Can you confirm if this is OK.

    Thanks,

    Regards,

    Aditi.

     

  • Yep, that should be OK.