This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down list at the bottom of the left panel and select the desired version.

Multi Producer Single Consumer Lock Free Queue

A Multi Producer Single Consumer Lock Free Queue (MPSC) is an lockfree intrusive queue based on atomic pointer swaps as described by Dmitry Vyukov at 1024cores.

API Reference

group mpsc_lockfree

Multiple Producer Single Consumer (MPSC) Lockfree Queue API.


mpsc_ptr_set(ptr, val)
mpsc_ptr_set_get(ptr, val)

Static initializer for a mpsc queue.

Since the queue is

  • symbol – name of the queue


typedef atomic_ptr_t mpsc_ptr_t


static inline void mpsc_init(struct mpsc *q)

Initialize queue.

  • q – Queue to initialize or reset

ALWAYS_INLINE static void mpsc_push(struct mpsc *q, struct mpsc_node *n)

Push a node.

  • q – Queue to push the node to

  • n – Node to push into the queue

static inline struct mpsc_node *mpsc_pop(struct mpsc *q)

Pop a node off of the list.

Return values:
  • NULL – When no node is available

  • node – When node is available

struct mpsc_node
#include <mpsc_lockfree.h>

Queue member.

struct mpsc
#include <mpsc_lockfree.h>

MPSC Queue.