Adelsbach Enhanced Threading Library Version 1.0.1

Manual Pages (DD-00013-002)

Enhanced Threading Library > smtx_trylock (3)
HTML TXT PDF PS
smtx_trylock(3) Library Functions Manual smtx_trylock(3)

smtx_trylockattempt to acquire a spinlock

library “threads”
#include <threadse.h>

int
smtx_trylock(smtx_t *s);

The function () will attempt to acquire a spinlock s. If the lock cannot be acquired the function will return a respective return code.

Upon success smtx_trylock() will return thrd_success if the lock has been acquired. If the lock is already acquired thrd_busy will be returned. In case of error thrd_error will be returned.

smtx_init(3) smtx_destroy(3) smtx_lock(3) smtx_unlock(3)

The smtx_trylock() function first appeared in the Adelsbach Enhanced Threading Library. MacOS support was added in version 1.0.1 using an implementation with atomic variables.

Jan Adelsbach <jan@jadelsbach.de>

March 30, 2025 Linux 6.13.6-1-default