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 best practice to post a value along

Other Parts Discussed in Thread: SYSBIOS

Hello everyone,

Target is C6678, Sysbios 6.37, XDCTools 3.25, CCS v6beta.

Here's what we want to do :

- Post a swi N times with N different values to be transmitted with the post

- Make sure we DONT lose any posted swi and the value associated

- Calling context of the 'post' range from Idle to Task to Swi to Hwi

- the same SWI can be called from different places in the code

Here's what we noticed :

Swi_or doesn't fit our needs because let's say the SWI is posted 3 times in a HWI context, the SWI will only execute once.

Swi_post isn't right either.

Swi_inc is OK with the repetitions = getTrigger and while loop as described in the SYSBIOS User Guide.

But we also need to pass an argument with the SWI.

 When the SWI is posted from a single place we used the following mechanism

Swi_getAttrs(swi_hdl, NULL, &param);
param.arg0 = (UArg) &event_table[0]; /* fixed pointer */
Swi_setAttrs(swi_hdl, NULL, &param);
Swi_inc(swi_hdl);

// in the SWI function
// getTrigger call to know the number of times the swi must // be executed
// read the event_table

My question is :

When a SWI is to be posted in A) a task context b) a SWI context,
what's the best strategy to make sure we don't lose 'posts' and have a 32-bit argument passed with each post ?

  • Clement,

    I don’t know if this is a “best practice”… but if the Swi can be posted multiple times before it runs, to pass a unique 32-bit value for each post of the Swi, I think you can use an additional queue to store the 32-bit values.  Use Queue_put() to put the data values into the queue, and then use Swi_inc() to post the Swi.  In your Swi function, use Queue_get() to read the values out of the queue, using the count from Swi_getTrigger() to know how many elements to read from the queue.
     
    Does this make sense?

    Scott

  • Scott,

    That's a good suggestion.

    For now in my case I used a simpler solution (based on a table of integers where the HWI is the Writer and the Swi the reader) that fits our needs.

    I'll keep in mind the Queue idea in case more complex cases arise.

    Thank you

    Clement