From: kosmirror <kos...@us...> - 2025-05-30 23:53:39
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 5494e88a4d4bab0a288892f55363e48a146417ff (commit) from 5f6cc322256b3c503b462f0a99b221ee304e5482 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5494e88a4d4bab0a288892f55363e48a146417ff Author: QuzarDC <qu...@co...> Date: Fri May 30 03:37:50 2025 -0400 Correct `mutex_trylock` errno. According to POSIX spec EBUSY should be returned for trylock when the mutex couldn't be locked. EAGAIN is instead used if the max number of recursive locks for the mutex has been exceeded. ----------------------------------------------------------------------- Summary of changes: include/kos/mutex.h | 2 +- kernel/libc/c11/mtx_trylock.c | 2 +- kernel/thread/mutex.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/kos/mutex.h b/include/kos/mutex.h index 67729b65..243b5cc6 100644 --- a/include/kos/mutex.h +++ b/include/kos/mutex.h @@ -239,7 +239,7 @@ int mutex_is_locked(mutex_t *m); \retval -1 If the mutex cannot be acquired without blocking \par Error Conditions: - \em EAGAIN - the mutex is already locked (mutex_lock() would block) \n + \em EBUSY - the mutex is already locked (mutex_lock() would block) \n \em EINVAL - the mutex has not been initialized properly \n \em EAGAIN - lock has been acquired too many times (recursive) \n \em EDEADLK - would deadlock (error-checking) diff --git a/kernel/libc/c11/mtx_trylock.c b/kernel/libc/c11/mtx_trylock.c index cb0e833b..eead66a0 100644 --- a/kernel/libc/c11/mtx_trylock.c +++ b/kernel/libc/c11/mtx_trylock.c @@ -9,7 +9,7 @@ int mtx_trylock(mtx_t *mtx) { if(mutex_trylock(mtx)) { - if(errno == EAGAIN) + if(errno == EBUSY) return thrd_busy; return thrd_error; diff --git a/kernel/thread/mutex.c b/kernel/thread/mutex.c index 4490ad63..09cdd3a5 100644 --- a/kernel/thread/mutex.c +++ b/kernel/thread/mutex.c @@ -198,7 +198,7 @@ int mutex_trylock(mutex_t *m) { /* Check if the lock is held by some other thread already */ if(m->count && m->holder != thd) { - errno = EAGAIN; + errno = EBUSY; return -1; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |