---
name: "rte_ticketlock.h"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_ticketlock.h"
---

# rte\_ticketlock.h(3)

## NAME

rte\_ticketlock.h

## SYNOPSIS

`#include <rte_common.h>`\
 `#include <rte_lcore.h>`\
 `#include <rte_pause.h>`\
 `#include <rte_stdatomic.h>`\

### 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 void **rte\_ticketlock\_init** (**rte\_ticketlock\_t** \*tl)\
 static void **rte\_ticketlock\_lock** (**rte\_ticketlock\_t** \*tl)\
 static void **rte\_ticketlock\_unlock** (**rte\_ticketlock\_t** \*tl)\
 static int **rte\_ticketlock\_trylock** (**rte\_ticketlock\_t** \*tl)\
 static int **rte\_ticketlock\_is\_locked** (**rte\_ticketlock\_t** \*tl)\
 static void **rte\_ticketlock\_recursive\_init** (rte\_ticketlock\_recursive\_t \*tlr)\
 static void **rte\_ticketlock\_recursive\_lock** (rte\_ticketlock\_recursive\_t \*tlr)\
 static void **rte\_ticketlock\_recursive\_unlock** (rte\_ticketlock\_recursive\_t \*tlr)\
 static 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

### #define RTE\_TICKETLOCK\_INITIALIZER { 0 }

A static ticketlock initializer.

Definition at line **43** of file **rte\_ticketlock.h**.

### #define TICKET\_LOCK\_INVALID\_ID -1

The rte\_ticketlock\_recursive\_t type.

Definition at line **128** of file **rte\_ticketlock.h**.

### #define RTE\_TICKETLOCK\_RECURSIVE\_INITIALIZER

**Value:**.PP

```
                          {RTE_TICKETLOCK_INITIALIZER, \
                          TICKET_LOCK_INVALID_ID, 0}
```

A static recursive ticketlock initializer.

Definition at line **139** of file **rte\_ticketlock.h**.

## Function Documentation

### static void rte\_ticketlock\_init (rte\_ticketlock\_t \* tl)` [inline]`, ` [static]`

Initialize the ticketlock to an unlocked state.

**Parameters**

*tl* A pointer to the ticketlock.

Definition at line **52** of file **rte\_ticketlock.h**.

### static void rte\_ticketlock\_lock (rte\_ticketlock\_t \* tl)` [inline]`, ` [static]`

Take the ticketlock.

**Parameters**

*tl* A pointer to the ticketlock.

Definition at line **64** of file **rte\_ticketlock.h**.

### static void rte\_ticketlock\_unlock (rte\_ticketlock\_t \* tl)` [inline]`, ` [static]`

Release the ticketlock.

**Parameters**

*tl* A pointer to the ticketlock.

Definition at line **78** of file **rte\_ticketlock.h**.

### static int rte\_ticketlock\_trylock (rte\_ticketlock\_t \* tl)` [inline]`, ` [static]`

Try to take the lock.

**Parameters**

*tl* A pointer to the ticketlock.

**Returns**

1 if the lock is successfully taken; 0 otherwise.

Definition at line **93** of file **rte\_ticketlock.h**.

### static int rte\_ticketlock\_is\_locked (rte\_ticketlock\_t \* tl)` [inline]`, ` [static]`

Test if the lock is taken.

**Parameters**

*tl* A pointer to the ticketlock.

**Returns**

1 if the lock is currently taken; 0 otherwise.

Definition at line **118** of file **rte\_ticketlock.h**.

### static void rte\_ticketlock\_recursive\_init (rte\_ticketlock\_recursive\_t \* tlr)` [inline]`, ` [static]`

Initialize the recursive ticketlock to an unlocked state.

**Parameters**

*tlr* A pointer to the recursive ticketlock.

Definition at line **149** of file **rte\_ticketlock.h**.

### static void rte\_ticketlock\_recursive\_lock (rte\_ticketlock\_recursive\_t \* tlr)` [inline]`, ` [static]`

Take the recursive ticketlock.

**Parameters**

*tlr* A pointer to the recursive ticketlock.

Definition at line **163** of file **rte\_ticketlock.h**.

### static void rte\_ticketlock\_recursive\_unlock (rte\_ticketlock\_recursive\_t \* tlr)` [inline]`, ` [static]`

Release the recursive ticketlock.

**Parameters**

*tlr* A pointer to the recursive ticketlock.

Definition at line **181** of file **rte\_ticketlock.h**.

### static int rte\_ticketlock\_recursive\_trylock (rte\_ticketlock\_recursive\_t \* tlr)` [inline]`, ` [static]`

Try to take the recursive lock.

**Parameters**

*tlr* A pointer to the recursive ticketlock.

**Returns**

1 if the lock is successfully taken; 0 otherwise.

Definition at line **199** of file **rte\_ticketlock.h**.

## Author

Generated automatically by Doxygen for DPDK from the source code.
