Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
rtio_mpsc.h File Reference

A wait-free intrusive multi producer single consumer (MPSC) queue using a singly linked list. More...

#include <stdint.h>
#include <stdbool.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/kernel.h>

Go to the source code of this file.

Data Structures

struct  rtio_mpsc_node
 Queue member. More...
 
struct  rtio_mpsc
 MPSC Queue. More...
 

Macros

#define mpsc_ptr_get(ptr)   atomic_ptr_get(&(ptr))
 
#define mpsc_ptr_set(ptr, val)   atomic_ptr_set(&(ptr), val)
 
#define mpsc_ptr_set_get(ptr, val)   atomic_ptr_set(&(ptr), val)
 
#define RTIO_MPSC_INIT(symbol)
 Static initializer for a mpsc queue.
 

Typedefs

typedef atomic_ptr_t mpsc_ptr_t
 

Functions

static void rtio_mpsc_init (struct rtio_mpsc *q)
 Initialize queue.
 
static ALWAYS_INLINE void rtio_mpsc_push (struct rtio_mpsc *q, struct rtio_mpsc_node *n)
 Push a node.
 
static struct rtio_mpsc_nodertio_mpsc_pop (struct rtio_mpsc *q)
 Pop a node off of the list.
 

Detailed Description

A wait-free intrusive multi producer single consumer (MPSC) queue using a singly linked list.

Ordering is First-In-First-Out.

Based on the well known and widely used wait-free MPSC queue described by Dmitry Vyukov with some slight changes to account for needs of an RTOS on a variety of archs. Both consumer and producer are wait free. No CAS loop or lock is needed.

An MPSC queue is safe to produce or consume in an ISR with O(1) push/pop.

Warning
MPSC is not safe to consume in multiple execution contexts.