RTE OSAdapter POSIX 0.1.0 build 41b3eb3
POSIX/Linux OAL OSAdapter for Platform_RTE
Loading...
Searching...
No Matches
rte_posix_osadapter_mutex.c File Reference

POSIX rte_mutex OSAdapter: a thin wrapper over pthread_mutex_t (ADR-033, safeAPIFreamwork). This is the ONE file in the whole stack allowed to touch pthread_mutex_* directly - see rte_mutex.h's own doc for why an application must never do so itself. More...

#include "rte/posix_osadapter/rte_posix_osadapter.h"
#include "rte_posix_osadapter_lock.h"
#include "rte_posix_osadapter_report.h"
#include <pthread.h>
#include "rte/oal/memory/rte_mem_util.h"
Include dependency graph for rte_posix_osadapter_mutex.c:

Go to the source code of this file.

Data Structures

struct  posix_mutex_state_t

Macros

#define _POSIX_C_SOURCE   200809L

Typedefs

typedef char posix_mutex_storage_fits_[(sizeof(posix_mutex_state_t)<=sizeof(rte_mutex_storage_t)) ? 1 :-1]

Functions

static rte_status_t osadapter_create (rte_mutex_storage_t *storage, rte_mutex_handle_t *out_handle)
static rte_status_t osadapter_lock (rte_mutex_handle_t handle)
static rte_status_t osadapter_unlock (rte_mutex_handle_t handle)
static rte_status_t osadapter_destroy (rte_mutex_handle_t handle)
static rte_status_t osadapter_lock_timed (rte_mutex_handle_t handle, rte_duration_ms_t timeout_ms)
const rte_osadapter_mutex_t * rte_posix_osadapter_mutex (void)
 The POSIX rte_mutex OSAdapter (a thin pthread_mutex_t wrapper, ADR-033).

Variables

static const rte_osadapter_mutex_t s_posix_mutex_osadapter

Detailed Description

POSIX rte_mutex OSAdapter: a thin wrapper over pthread_mutex_t (ADR-033, safeAPIFreamwork). This is the ONE file in the whole stack allowed to touch pthread_mutex_* directly - see rte_mutex.h's own doc for why an application must never do so itself.

Every mutex is created with PTHREAD_PRIO_INHERIT (OSA rule R2, REQ-OAL-MUTEX-004). If the host refuses priority inheritance, create fails with RTE_STATUS_INTERNAL_ERROR and reports the refusal as DEGRADED / RTE_SAFESTATE_REASON_OSA_RT_ATTRIBUTE; it never falls back to a plain mutex.

lock_timed (OSA rule R2, REQ-OAL-MUTEX-014) waits at most timeout_ms; timeout_ms == 0 is one pthread_mutex_trylock(). A failed clock read returns RTE_STATUS_INTERNAL_ERROR, never an unbounded wait. The wait is posix_osa_lock_bounded() (rte_posix_osadapter_lock.c), shared with the memory OSAdapter's pool lock; its header documents the two host variants (Linux: pthread_mutex_timedlock() on a CLOCK_REALTIME deadline, keeps the priority-inheritance boost, a wall-clock step shortens or lengthens one wait; other hosts: a trylock loop on a CLOCK_MONOTONIC deadline with no priority-inheritance boost while polling - development host only).

Definition in file rte_posix_osadapter_mutex.c.

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

Definition at line 3 of file rte_posix_osadapter_mutex.c.

Typedef Documentation

◆ posix_mutex_storage_fits_

typedef char posix_mutex_storage_fits_[(sizeof(posix_mutex_state_t)<=sizeof(rte_mutex_storage_t)) ? 1 :-1]

Definition at line 48 of file rte_posix_osadapter_mutex.c.

Function Documentation

◆ osadapter_create()

rte_status_t osadapter_create ( rte_mutex_storage_t * storage,
rte_mutex_handle_t * out_handle )
static

Local function declarations

Definition at line 73 of file rte_posix_osadapter_mutex.c.

◆ osadapter_destroy()

rte_status_t osadapter_destroy ( rte_mutex_handle_t handle)
static

Definition at line 158 of file rte_posix_osadapter_mutex.c.

◆ osadapter_lock()

rte_status_t osadapter_lock ( rte_mutex_handle_t handle)
static

Definition at line 128 of file rte_posix_osadapter_mutex.c.

◆ osadapter_lock_timed()

rte_status_t osadapter_lock_timed ( rte_mutex_handle_t handle,
rte_duration_ms_t timeout_ms )
static

Definition at line 173 of file rte_posix_osadapter_mutex.c.

◆ osadapter_unlock()

rte_status_t osadapter_unlock ( rte_mutex_handle_t handle)
static

Definition at line 143 of file rte_posix_osadapter_mutex.c.

◆ rte_posix_osadapter_mutex()

const rte_osadapter_mutex_t * rte_posix_osadapter_mutex ( void )

The POSIX rte_mutex OSAdapter (a thin pthread_mutex_t wrapper, ADR-033).

Global variables declarations Global functions

Definition at line 65 of file rte_posix_osadapter_mutex.c.

Variable Documentation

◆ s_posix_mutex_osadapter

const rte_osadapter_mutex_t s_posix_mutex_osadapter
static
Initial value:
= { osadapter_create, osadapter_lock, osadapter_unlock,
osadapter_destroy, osadapter_lock_timed }
static rte_status_t osadapter_create(rte_mutex_storage_t *storage, rte_mutex_handle_t *out_handle)

Local variables declarations

Definition at line 58 of file rte_posix_osadapter_mutex.c.