---
name: "rte_mcslock_is_locked"
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_mcslock.h"
---

# rte\_mcslock\_is\_locked(3)

Part of [rte\_mcslock.h(3)](/rte_mcslock.h/3.md).

## 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>`\

### Data Structures

struct **rte\_mcslock**\

### Typedefs

**typedef** struct **rte\_mcslock** **rte\_mcslock\_t**\

### Functions

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)\

## 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

### typedef struct rte\_mcslock rte\_mcslock\_t

The rte\_mcslock\_t type.

## Function Documentation

### static void rte\_mcslock\_lock (1(rte\_mcslock\_t \*) \* msl, rte\_mcslock\_t \* me)` [inline]`, ` [static]`

Take the MCS lock.

**Parameters**

*msl* 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**.

### static void rte\_mcslock\_unlock (1(rte\_mcslock\_t \*) \* msl, 1(rte\_mcslock\_t \*) me)` [inline]`, ` [static]`

Release the MCS lock.

**Parameters**

*msl* 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 **116** of file **rte\_mcslock.h**.

### static int rte\_mcslock\_trylock (1(rte\_mcslock\_t \*) \* msl, rte\_mcslock\_t \* me)` [inline]`, ` [static]`

Try to take the lock.

**Parameters**

*msl* 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 **172** of file **rte\_mcslock.h**.

### static int rte\_mcslock\_is\_locked (1(rte\_mcslock\_t \*) msl)` [inline]`, ` [static]`

Test if the lock is taken.

**Parameters**

*msl* A pointer to a MCS lock node.

**Returns**

1 if the lock is currently taken; 0 otherwise.

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

## Author

Generated automatically by Doxygen for DPDK from the source code.
