DPDK  19.11.14
Data Structures | Macros | Functions
rte_ticketlock.h File Reference
#include <rte_common.h>
#include <rte_lcore.h>
#include <rte_pause.h>

Go to the source code of this file.

Data Structures

union  rte_ticketlock_t
 

Macros

#define RTE_TICKETLOCK_INITIALIZER   { 0 }
 
#define TICKET_LOCK_INVALID_ID   -1
 
#define RTE_TICKETLOCK_RECURSIVE_INITIALIZER
 

Functions

static __rte_experimental void rte_ticketlock_init (rte_ticketlock_t *tl)
 
static __rte_experimental void rte_ticketlock_lock (rte_ticketlock_t *tl)
 
static __rte_experimental void rte_ticketlock_unlock (rte_ticketlock_t *tl)
 
static __rte_experimental int rte_ticketlock_trylock (rte_ticketlock_t *tl)
 
static __rte_experimental int rte_ticketlock_is_locked (rte_ticketlock_t *tl)
 
static __rte_experimental void rte_ticketlock_recursive_init (rte_ticketlock_recursive_t *tlr)
 
static __rte_experimental void rte_ticketlock_recursive_lock (rte_ticketlock_recursive_t *tlr)
 
static __rte_experimental void rte_ticketlock_recursive_unlock (rte_ticketlock_recursive_t *tlr)
 
static __rte_experimental int rte_ticketlock_recursive_trylock (rte_ticketlock_recursive_t *tlr)
 

Detailed Description

RTE ticket locks

This file defines an API for ticket locks, which give each waiting thread a ticket and take the lock one by one, first come, first serviced.

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

Definition in file rte_ticketlock.h.

Macro Definition Documentation

◆ RTE_TICKETLOCK_INITIALIZER

#define RTE_TICKETLOCK_INITIALIZER   { 0 }

A static ticketlock initializer.

Definition at line 43 of file rte_ticketlock.h.

◆ TICKET_LOCK_INVALID_ID

#define TICKET_LOCK_INVALID_ID   -1

The rte_ticketlock_recursive_t type.

Definition at line 132 of file rte_ticketlock.h.

◆ RTE_TICKETLOCK_RECURSIVE_INITIALIZER

#define RTE_TICKETLOCK_RECURSIVE_INITIALIZER
Value:
TICKET_LOCK_INVALID_ID, 0}
#define RTE_TICKETLOCK_INITIALIZER

A static recursive ticketlock initializer.

Definition at line 143 of file rte_ticketlock.h.

Function Documentation

◆ rte_ticketlock_init()

static __rte_experimental void rte_ticketlock_init ( rte_ticketlock_t tl)
inlinestatic

Initialize the ticketlock to an unlocked state.

Parameters
tlA pointer to the ticketlock.

Definition at line 53 of file rte_ticketlock.h.

◆ rte_ticketlock_lock()

static __rte_experimental void rte_ticketlock_lock ( rte_ticketlock_t tl)
inlinestatic

Take the ticketlock.

Parameters
tlA pointer to the ticketlock.

Definition at line 66 of file rte_ticketlock.h.

◆ rte_ticketlock_unlock()

static __rte_experimental void rte_ticketlock_unlock ( rte_ticketlock_t tl)
inlinestatic

Release the ticketlock.

Parameters
tlA pointer to the ticketlock.

Definition at line 81 of file rte_ticketlock.h.

◆ rte_ticketlock_trylock()

static __rte_experimental int rte_ticketlock_trylock ( rte_ticketlock_t tl)
inlinestatic

Try to take the lock.

Parameters
tlA pointer to the ticketlock.
Returns
1 if the lock is successfully taken; 0 otherwise.

Definition at line 97 of file rte_ticketlock.h.

◆ rte_ticketlock_is_locked()

static __rte_experimental int rte_ticketlock_is_locked ( rte_ticketlock_t tl)
inlinestatic

Test if the lock is taken.

Parameters
tlA pointer to the ticketlock.
Returns
1 if the lock is currently taken; 0 otherwise.

Definition at line 122 of file rte_ticketlock.h.

◆ rte_ticketlock_recursive_init()

static __rte_experimental void rte_ticketlock_recursive_init ( rte_ticketlock_recursive_t *  tlr)
inlinestatic

Initialize the recursive ticketlock to an unlocked state.

Parameters
tlrA pointer to the recursive ticketlock.

Definition at line 154 of file rte_ticketlock.h.

◆ rte_ticketlock_recursive_lock()

static __rte_experimental void rte_ticketlock_recursive_lock ( rte_ticketlock_recursive_t *  tlr)
inlinestatic

Take the recursive ticketlock.

Parameters
tlrA pointer to the recursive ticketlock.

Definition at line 169 of file rte_ticketlock.h.

◆ rte_ticketlock_recursive_unlock()

static __rte_experimental void rte_ticketlock_recursive_unlock ( rte_ticketlock_recursive_t *  tlr)
inlinestatic

Release the recursive ticketlock.

Parameters
tlrA pointer to the recursive ticketlock.

Definition at line 188 of file rte_ticketlock.h.

◆ rte_ticketlock_recursive_trylock()

static __rte_experimental int rte_ticketlock_recursive_trylock ( rte_ticketlock_recursive_t *  tlr)
inlinestatic

Try to take the recursive lock.

Parameters
tlrA pointer to the recursive ticketlock.
Returns
1 if the lock is successfully taken; 0 otherwise.

Definition at line 207 of file rte_ticketlock.h.