rte_mcslock.h
Contents
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.
Function Documentation
staticvoidrte_mcslock_lock(1(rte_mcslock_t*)*msl,rte_mcslock_t*me)[inline],[static]
Take the MCS lock.
Parametersmsl A pointer to the pointer of a MCS lock. When the lock is initialized or declared, the msl pointer
should be set to NULL.
me A pointer to a new node of MCS lock. Each CPU/thread acquiring the lock should use its 'own node'.
Definition at line 52 of file rte_mcslock.h.
staticvoidrte_mcslock_unlock(1(rte_mcslock_t*)*msl,1(rte_mcslock_t*)me)[inline],[static]
Release the MCS lock.
Parametersmsl A pointer to the pointer of a MCS lock.
me A pointer to the node of MCS lock passed in rte_mcslock_lock.
Definition at line 104 of file rte_mcslock.h.
staticintrte_mcslock_trylock(1(rte_mcslock_t*)*msl,rte_mcslock_t*me)[inline],[static]
Try to take the lock.
Parametersmsl A pointer to the pointer of a MCS lock.
me A pointer to a new node of MCS lock.
Returns
1 if the lock is successfully taken; 0 otherwise.
Definition at line 144 of file rte_mcslock.h.
staticintrte_mcslock_is_locked(1(rte_mcslock_t*)msl)[inline],[static]
Test if the lock is taken.
Parametersmsl A pointer to a MCS lock node.
Returns
1 if the lock is currently taken; 0 otherwise.
Definition at line 171 of file rte_mcslock.h.
Name
rte_mcslock.h
Synopsis
#include <rte_lcore.h>
#include <rte_common.h>
#include <rte_pause.h>
#include <rte_branch_prediction.h>
#include <rte_stdatomic.h>
DataStructures
struct rte_mcslockTypedefstypedef struct rte_mcslockrte_mcslock_tFunctions
static void rte_mcslock_lock (1(rte_mcslock_t *) *msl, rte_mcslock_t *me)
static void rte_mcslock_unlock (1(rte_mcslock_t *) *msl, 1(rte_mcslock_t *) me)
static int rte_mcslock_trylock (1(rte_mcslock_t *) *msl, rte_mcslock_t *me)
static int rte_mcslock_is_locked (1(rte_mcslock_t *) msl)
Typedef Documentation
typedefstructrte_mcslockrte_mcslock_t
The rte_mcslock_t type.
