|
RTE OSAdapter POSIX 0.1.0 build 41b3eb3
POSIX/Linux OAL OSAdapter for Platform_RTE
|
Bounded wait for a pthread mutex (OSA rule R2), shared by the mutex OSAdapter's lock_timed (REQ-OAL-MUTEX-014) and the memory OSAdapter's pool lock (REQ-OAL-MEM-015). Semantics and the two host variants are documented on posix_osa_lock_bounded() in rte_posix_osadapter_lock.h. Moved here unchanged from rte_posix_osadapter_mutex.c (2026-10-03) so both callers use one implementation. More...
#include "rte_posix_osadapter_lock.h"#include <errno.h>#include <pthread.h>#include <stdbool.h>#include <stdint.h>#include <time.h>Go to the source code of this file.
Macros | |
| #define | _POSIX_C_SOURCE 200809L |
| #define | POSIX_LOCK_NS_PER_MS 1000000L |
| #define | POSIX_LOCK_NS_PER_S 1000000000L |
| #define | POSIX_LOCK_POLL_NS 1000000L |
Functions | |
| static rte_status_t | try_lock_once (pthread_mutex_t *mutex) |
| static rte_status_t | lock_until_deadline (pthread_mutex_t *mutex, rte_duration_ms_t timeout_ms) |
| static void | deadline_add_ms (struct timespec *ts, rte_duration_ms_t ms) |
| rte_status_t | posix_osa_lock_bounded (pthread_mutex_t *mutex, rte_duration_ms_t timeout_ms) |
| Waits at most timeout_ms for a pthread mutex. | |
Bounded wait for a pthread mutex (OSA rule R2), shared by the mutex OSAdapter's lock_timed (REQ-OAL-MUTEX-014) and the memory OSAdapter's pool lock (REQ-OAL-MEM-015). Semantics and the two host variants are documented on posix_osa_lock_bounded() in rte_posix_osadapter_lock.h. Moved here unchanged from rte_posix_osadapter_mutex.c (2026-10-03) so both callers use one implementation.
Definition in file rte_posix_osadapter_lock.c.
| #define _POSIX_C_SOURCE 200809L |
Definition at line 3 of file rte_posix_osadapter_lock.c.
| #define POSIX_LOCK_NS_PER_MS 1000000L |
Local makros
Definition at line 24 of file rte_posix_osadapter_lock.c.
| #define POSIX_LOCK_NS_PER_S 1000000000L |
Definition at line 25 of file rte_posix_osadapter_lock.c.
| #define POSIX_LOCK_POLL_NS 1000000L |
Sleep between two trylock attempts of the polling timed lock (1 ms).
Definition at line 28 of file rte_posix_osadapter_lock.c.
|
static |
Adds ms to ts, keeping tv_nsec in [0, 1 s).
Definition at line 176 of file rte_posix_osadapter_lock.c.
|
static |
trylock loop against a CLOCK_MONOTONIC deadline; each sleep is at most POSIX_LOCK_POLL_NS and never past the deadline, so the loop ends at the deadline (no PI boost while polling, see the header).
Definition at line 123 of file rte_posix_osadapter_lock.c.
| rte_status_t posix_osa_lock_bounded | ( | pthread_mutex_t * | mutex, |
| rte_duration_ms_t | timeout_ms ) |
Waits at most timeout_ms for a pthread mutex.
Local variables declarations Global variables declarations Global functions
timeout_ms == 0 is one pthread_mutex_trylock(). Otherwise:
A failed clock read returns RTE_STATUS_INTERNAL_ERROR, never an unbounded wait.
| mutex | Initialised pthread mutex to lock. Must not be NULL. |
| timeout_ms | Maximum time to wait, in milliseconds; 0 is one non-blocking try. |
Definition at line 44 of file rte_posix_osadapter_lock.c.
|
static |
Local types declarations Local function declarations
One pthread_mutex_trylock(): OK when acquired, TIMEOUT when another task holds the mutex, INTERNAL_ERROR else.
Definition at line 68 of file rte_posix_osadapter_lock.c.