DPDK  18.11.11
Data Structures | Macros | Functions
rte_rwlock.h File Reference
#include <rte_common.h>
#include <rte_atomic.h>
#include <rte_pause.h>

Go to the source code of this file.

Data Structures

struct  rte_rwlock_t
 

Macros

#define RTE_RWLOCK_INITIALIZER   { 0 }
 

Functions

static void rte_rwlock_init (rte_rwlock_t *rwl)
 
static void rte_rwlock_read_lock (rte_rwlock_t *rwl)
 
static void rte_rwlock_read_unlock (rte_rwlock_t *rwl)
 
static void rte_rwlock_write_lock (rte_rwlock_t *rwl)
 
static void rte_rwlock_write_unlock (rte_rwlock_t *rwl)
 
static void rte_rwlock_read_lock_tm (rte_rwlock_t *rwl)
 
static void rte_rwlock_read_unlock_tm (rte_rwlock_t *rwl)
 
static void rte_rwlock_write_lock_tm (rte_rwlock_t *rwl)
 
static void rte_rwlock_write_unlock_tm (rte_rwlock_t *rwl)
 

Detailed Description

RTE Read-Write Locks

This file defines an API for read-write locks. The lock is used to protect data that allows multiple readers in parallel, but only one writer. All readers are blocked until the writer is finished writing.

Definition in file rte_rwlock.h.

Macro Definition Documentation

#define RTE_RWLOCK_INITIALIZER   { 0 }

A static rwlock initializer.

Definition at line 40 of file rte_rwlock.h.

Function Documentation

static void rte_rwlock_init ( rte_rwlock_t rwl)
inlinestatic

Initialize the rwlock to an unlocked state.

Parameters
rwlA pointer to the rwlock structure.

Definition at line 49 of file rte_rwlock.h.

static void rte_rwlock_read_lock ( rte_rwlock_t rwl)
inlinestatic

Take a read lock. Loop until the lock is held.

Parameters
rwlA pointer to a rwlock structure.

Definition at line 61 of file rte_rwlock.h.

static void rte_rwlock_read_unlock ( rte_rwlock_t rwl)
inlinestatic

Release a read lock.

Parameters
rwlA pointer to the rwlock structure.

Definition at line 85 of file rte_rwlock.h.

static void rte_rwlock_write_lock ( rte_rwlock_t rwl)
inlinestatic

Take a write lock. Loop until the lock is held.

Parameters
rwlA pointer to a rwlock structure.

Definition at line 97 of file rte_rwlock.h.

static void rte_rwlock_write_unlock ( rte_rwlock_t rwl)
inlinestatic

Release a write lock.

Parameters
rwlA pointer to a rwlock structure.

Definition at line 121 of file rte_rwlock.h.

static void rte_rwlock_read_lock_tm ( rte_rwlock_t rwl)
inlinestatic

Try to execute critical section in a hardware memory transaction, if it fails or not available take a read lock

NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail. Therefore, hardware transactional locks are not advised to be used around rte_eth_rx_burst() and rte_eth_tx_burst() calls.

Parameters
rwlA pointer to a rwlock structure.
static void rte_rwlock_read_unlock_tm ( rte_rwlock_t rwl)
inlinestatic

Commit hardware memory transaction or release the read lock if the lock is used as a fall-back

Parameters
rwlA pointer to the rwlock structure.
static void rte_rwlock_write_lock_tm ( rte_rwlock_t rwl)
inlinestatic

Try to execute critical section in a hardware memory transaction, if it fails or not available take a write lock

NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail. Therefore, hardware transactional locks are not advised to be used around rte_eth_rx_burst() and rte_eth_tx_burst() calls.

Parameters
rwlA pointer to a rwlock structure.
static void rte_rwlock_write_unlock_tm ( rte_rwlock_t rwl)
inlinestatic

Commit hardware memory transaction or release the write lock if the lock is used as a fall-back

Parameters
rwlA pointer to a rwlock structure.