This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multi threaded queue access

SDK14.2

A little background on this question.


I am creating a library where I need to add items to a queue and then process those items from the queue. I would like to know what SDK library would be better for this operation:
nrf_queue or nrf_atfifo library.

Basically, here is an example of how my library would work:


Someone can call DoFooA() from one thread and somone else can call DoFooB() from another thread. Both of these items will be added to the queue and the scheduler will call the process queue function some time and that function will process the items in the queue.

My question is what library should I use for this the nrf_queue library or the nrf_atfifo. Would there be any thread safety issues?

DoFooA(itemA)
{

addToQueue(itemA);
app_sched_event_put(NULL, 0, DoProcessQueue);
return SUCCESS

}


DoFooB(itemB)
{

addToQueue(itemB);
app_sched_event_put(NULL, 0, DoProcessQueue);
return SUCCESS

}


DoFooC(itemC)
{

addToQueue(itemC);
app_sched_event_put(NULL, 0, DoProcessQueue);
return SUCCESS

}


DoProcessQueue(void)
{
//process all the items in the queue here


}

Parents
  • Hi Superpak,

    I think your question is if nrf_queue or nrf_fifo library is best suited for you?

    nrf_fifo is designed to work with bytes of data data where as queues implementation is more of object oriented concepts where you can push and pop pre defined objects. Also the queues are documented to be more interrupt safe and i am quite positive that nrf_fifo has not been tested to be interrupt safe.

    I would have used queues if it were me to choose.

     

Reply
  • Hi Superpak,

    I think your question is if nrf_queue or nrf_fifo library is best suited for you?

    nrf_fifo is designed to work with bytes of data data where as queues implementation is more of object oriented concepts where you can push and pop pre defined objects. Also the queues are documented to be more interrupt safe and i am quite positive that nrf_fifo has not been tested to be interrupt safe.

    I would have used queues if it were me to choose.

     

Children
No Data
Related