Skip to content

Commit

Permalink
Add some clarification comments on the mutex api
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt authored and linguini1 committed Dec 27, 2024
1 parent b514e2a commit c8f5451
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
18 changes: 15 additions & 3 deletions include/nuttx/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int nxmutex_destroy(FAR mutex_t *mutex);
* Name: nxmutex_is_hold
*
* Description:
* This function check whether the caller hold the mutex
* This function check whether the calling thread hold the mutex
* referenced by 'mutex'.
*
* Parameters:
Expand All @@ -141,6 +141,8 @@ bool nxmutex_is_hold(FAR mutex_t *mutex);
*
* Description:
* This function get the holder of the mutex referenced by 'mutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* mutex - mutex descriptor.
Expand All @@ -156,6 +158,8 @@ int nxmutex_get_holder(FAR mutex_t *mutex);
*
* Description:
* This function get the lock state the mutex referenced by 'mutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* mutex - mutex descriptor.
Expand Down Expand Up @@ -444,7 +448,7 @@ int nxrmutex_destroy(FAR rmutex_t *rmutex);
* Name: nxrmutex_is_hold
*
* Description:
* This function check whether the caller hold the recursive mutex
* This function check whether the calling thread hold the recursive mutex
* referenced by 'rmutex'.
*
* Parameters:
Expand All @@ -460,7 +464,11 @@ bool nxrmutex_is_hold(FAR rmutex_t *rmutex);
* Name: nxrmutex_is_recursive
*
* Description:
* This function check whether the recursive mutex is recursive
* This function check whether the recursive mutex is currently held
* recursively. That is, whether it's locked more than once by the
* current holder.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* rmutex - Recursive mutex descriptor.
Expand All @@ -477,6 +485,8 @@ bool nxrmutex_is_recursive(FAR rmutex_t *rmutex);
*
* Description:
* This function get the holder of the mutex referenced by 'mutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* rmutex - Rmutex descriptor.
Expand All @@ -493,6 +503,8 @@ int nxrmutex_get_holder(FAR rmutex_t *rmutex);
* Description:
* This function get the lock state the recursive mutex
* referenced by 'rmutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* rmutex - Recursive mutex descriptor.
Expand Down
18 changes: 15 additions & 3 deletions libs/libc/misc/lib_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ int nxmutex_destroy(FAR mutex_t *mutex)
* Name: nxmutex_is_hold
*
* Description:
* This function check whether the caller hold the mutex
* This function check whether the calling thread hold the mutex
* referenced by 'mutex'.
*
* Parameters:
Expand All @@ -185,6 +185,8 @@ bool nxmutex_is_hold(FAR mutex_t *mutex)
*
* Description:
* This function get the holder of the mutex referenced by 'mutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* mutex - mutex descriptor.
Expand All @@ -203,6 +205,8 @@ int nxmutex_get_holder(FAR mutex_t *mutex)
*
* Description:
* This function get the lock state the mutex referenced by 'mutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* mutex - mutex descriptor.
Expand Down Expand Up @@ -645,7 +649,7 @@ int nxrmutex_destroy(FAR rmutex_t *rmutex)
* Name: nxrmutex_is_hold
*
* Description:
* This function check whether the caller hold the recursive mutex
* This function check whether the calling thread hold the recursive mutex
* referenced by 'rmutex'.
*
* Parameters:
Expand All @@ -664,7 +668,11 @@ bool nxrmutex_is_hold(FAR rmutex_t *rmutex)
* Name: nxrmutex_is_recursive
*
* Description:
* This function check whether the recursive mutex is recursive
* This function check whether the recursive mutex is currently held
* recursively. That is, whether it's locked more than once by the
* current holder.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* rmutex - Recursive mutex descriptor.
Expand All @@ -684,6 +692,8 @@ bool nxrmutex_is_recursive(FAR rmutex_t *rmutex)
*
* Description:
* This function get the holder of the mutex referenced by 'mutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* rmutex - Rmutex descriptor.
Expand All @@ -703,6 +713,8 @@ int nxrmutex_get_holder(FAR rmutex_t *rmutex)
* Description:
* This function get the lock state the recursive mutex
* referenced by 'rmutex'.
* Note that this is inherently racy unless the calling thread is
* holding the mutex.
*
* Parameters:
* rmutex - Recursive mutex descriptor.
Expand Down

0 comments on commit c8f5451

Please sign in to comment.