DPDK  19.11.14
Data Structures | Typedefs | Functions
rte_mcslock.h File Reference
#include <rte_lcore.h>
#include <rte_common.h>
#include <rte_pause.h>
#include <rte_branch_prediction.h>

Go to the source code of this file.

Data Structures

struct  rte_mcslock
 

Typedefs

typedef struct rte_mcslock rte_mcslock_t
 

Functions

static __rte_experimental void rte_mcslock_lock (rte_mcslock_t **msl, rte_mcslock_t *me)
 
static __rte_experimental void rte_mcslock_unlock (rte_mcslock_t **msl, rte_mcslock_t *me)
 
static __rte_experimental int rte_mcslock_trylock (rte_mcslock_t **msl, rte_mcslock_t *me)
 
static __rte_experimental int rte_mcslock_is_locked (rte_mcslock_t *msl)
 

Detailed Description

RTE MCS lock

This file defines the main data structure and APIs for MCS queued lock.

The MCS lock (proposed by John M. Mellor-Crummey and Michael L. Scott) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.

Definition in file rte_mcslock.h.

Typedef Documentation

◆ rte_mcslock_t

typedef struct rte_mcslock rte_mcslock_t

The rte_mcslock_t type.

Function Documentation

◆ rte_mcslock_lock()

static __rte_experimental void rte_mcslock_lock ( rte_mcslock_t **  msl,
rte_mcslock_t me 
)
inlinestatic
Warning
EXPERIMENTAL: This API may change without prior notice

Take the MCS lock.

Parameters
mslA pointer to the pointer of a MCS lock. When the lock is initialized or declared, the msl pointer should be set to NULL.
meA pointer to a new node of MCS lock. Each CPU/thread acquiring the lock should use its 'own node'.

Definition at line 51 of file rte_mcslock.h.

◆ rte_mcslock_unlock()

static __rte_experimental void rte_mcslock_unlock ( rte_mcslock_t **  msl,
rte_mcslock_t me 
)
inlinestatic
Warning
EXPERIMENTAL: This API may change without prior notice

Release the MCS lock.

Parameters
mslA pointer to the pointer of a MCS lock.
meA pointer to the node of MCS lock passed in rte_mcslock_lock.

Definition at line 108 of file rte_mcslock.h.

◆ rte_mcslock_trylock()

static __rte_experimental int rte_mcslock_trylock ( rte_mcslock_t **  msl,
rte_mcslock_t me 
)
inlinestatic
Warning
EXPERIMENTAL: This API may change without prior notice

Try to take the lock.

Parameters
mslA pointer to the pointer of a MCS lock.
meA pointer to a new node of MCS lock.
Returns
1 if the lock is successfully taken; 0 otherwise.

Definition at line 151 of file rte_mcslock.h.

◆ rte_mcslock_is_locked()

static __rte_experimental int rte_mcslock_is_locked ( rte_mcslock_t msl)
inlinestatic
Warning
EXPERIMENTAL: This API may change without prior notice

Test if the lock is taken.

Parameters
mslA pointer to a MCS lock node.
Returns
1 if the lock is currently taken; 0 otherwise.

Definition at line 182 of file rte_mcslock.h.