DPDK  2.0.0
Data Structures | Macros | Functions
rte_spinlock.h File Reference
#include <rte_lcore.h>

Data Structures

struct  rte_spinlock_t
struct  rte_spinlock_recursive_t

Macros

#define RTE_SPINLOCK_INITIALIZER   { 0 }
#define RTE_SPINLOCK_RECURSIVE_INITIALIZER   {RTE_SPINLOCK_INITIALIZER, -1, 0}

Functions

static void rte_spinlock_init (rte_spinlock_t *sl)
static void rte_spinlock_lock (rte_spinlock_t *sl)
static void rte_spinlock_unlock (rte_spinlock_t *sl)
static int rte_spinlock_trylock (rte_spinlock_t *sl)
static int rte_spinlock_is_locked (rte_spinlock_t *sl)
static void rte_spinlock_recursive_init (rte_spinlock_recursive_t *slr)
static void rte_spinlock_recursive_lock (rte_spinlock_recursive_t *slr)
static void rte_spinlock_recursive_unlock (rte_spinlock_recursive_t *slr)
static int rte_spinlock_recursive_trylock (rte_spinlock_recursive_t *slr)

Detailed Description

RTE Spinlocks

This file defines an API for read-write locks, which are implemented in an architecture-specific way. This kind of lock simply waits in a loop repeatedly checking until the lock becomes available.

All locks must be initialised before use, and only initialised once.

Macro Definition Documentation

#define RTE_SPINLOCK_INITIALIZER   { 0 }

A static spinlock initializer.

#define RTE_SPINLOCK_RECURSIVE_INITIALIZER   {RTE_SPINLOCK_INITIALIZER, -1, 0}

A static recursive spinlock initializer.

Function Documentation

static void rte_spinlock_init ( rte_spinlock_t sl)
inlinestatic

Initialize the spinlock to an unlocked state.

Parameters
slA pointer to the spinlock.
static int rte_spinlock_is_locked ( rte_spinlock_t sl)
inlinestatic

Test if the lock is taken.

Parameters
slA pointer to the spinlock.
Returns
1 if the lock is currently taken; 0 otherwise.
static void rte_spinlock_lock ( rte_spinlock_t sl)
inlinestatic

Take the spinlock.

Parameters
slA pointer to the spinlock.
static void rte_spinlock_recursive_init ( rte_spinlock_recursive_t slr)
inlinestatic

Initialize the recursive spinlock to an unlocked state.

Parameters
slrA pointer to the recursive spinlock.
static void rte_spinlock_recursive_lock ( rte_spinlock_recursive_t slr)
inlinestatic

Take the recursive spinlock.

Parameters
slrA pointer to the recursive spinlock.
static int rte_spinlock_recursive_trylock ( rte_spinlock_recursive_t slr)
inlinestatic

Try to take the recursive lock.

Parameters
slrA pointer to the recursive spinlock.
Returns
1 if the lock is successfully taken; 0 otherwise.
static void rte_spinlock_recursive_unlock ( rte_spinlock_recursive_t slr)
inlinestatic

Release the recursive spinlock.

Parameters
slrA pointer to the recursive spinlock.
static int rte_spinlock_trylock ( rte_spinlock_t sl)
inlinestatic

Try to take the lock.

Parameters
slA pointer to the spinlock.
Returns
1 if the lock is successfully taken; 0 otherwise.
static void rte_spinlock_unlock ( rte_spinlock_t sl)
inlinestatic

Release the spinlock.

Parameters
slA pointer to the spinlock.