Zephyr alternative to NRF_ATFIFO

I'm currently porting an existing NRF SDK code base to NRF Connect SDK (Zephyr)..

Our existing code used NRF_ATFIFO to communicate events from interrupts and multiple subsystems.  Upon inserting an event into the NRF_ATFIFO, processing is scheduled based on an atomic flag.  The processing would pop the events from the NRF_ATFIFO so they would be processed in order.

Important attributes of this system:

* lock free, and thread safe to use from ISR or scheduled events

* statically allocated

* multiple producers, single consumer

* producers do not have pre-determined resource allocations

* low overhead insertion

I cannot find an equivalent replacement within Zephyr's API's.

K_fifo uses linked lists and requires the producer to provide the data storage, or alternatively uses dynamic allocation.

MPSC is same as k_fifo (linked list, producer provides memory)

ring buffer is not lock-free / thread safe

I considered porting nordic's atfifo but it relies on assembly functions that I expect will create issues.

I would like something like 

https://github.com/max0x7ba/atomic_queue

but in a C implementation instead of C++.

Since Nordic has abandoned the NRF SDK, it would be nice if we at least had equivalent capabilities in the replacement..

Related