Skip to content

Commit 958e30b

Browse files
yamtxiaoxiang781216
authored andcommitted
Add some clarification comments on the mutex api
1 parent 28937fe commit 958e30b

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

include/nuttx/mutex.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int nxmutex_destroy(FAR mutex_t *mutex);
124124
* Name: nxmutex_is_hold
125125
*
126126
* Description:
127-
* This function check whether the caller hold the mutex
127+
* This function check whether the calling thread hold the mutex
128128
* referenced by 'mutex'.
129129
*
130130
* Parameters:
@@ -141,6 +141,8 @@ bool nxmutex_is_hold(FAR mutex_t *mutex);
141141
*
142142
* Description:
143143
* This function get the holder of the mutex referenced by 'mutex'.
144+
* Note that this is inherently racy unless the calling thread is
145+
* holding the mutex.
144146
*
145147
* Parameters:
146148
* mutex - mutex descriptor.
@@ -156,6 +158,8 @@ int nxmutex_get_holder(FAR mutex_t *mutex);
156158
*
157159
* Description:
158160
* This function get the lock state the mutex referenced by 'mutex'.
161+
* Note that this is inherently racy unless the calling thread is
162+
* holding the mutex.
159163
*
160164
* Parameters:
161165
* mutex - mutex descriptor.
@@ -444,7 +448,7 @@ int nxrmutex_destroy(FAR rmutex_t *rmutex);
444448
* Name: nxrmutex_is_hold
445449
*
446450
* Description:
447-
* This function check whether the caller hold the recursive mutex
451+
* This function check whether the calling thread hold the recursive mutex
448452
* referenced by 'rmutex'.
449453
*
450454
* Parameters:
@@ -460,7 +464,11 @@ bool nxrmutex_is_hold(FAR rmutex_t *rmutex);
460464
* Name: nxrmutex_is_recursive
461465
*
462466
* Description:
463-
* This function check whether the recursive mutex is recursive
467+
* This function check whether the recursive mutex is currently held
468+
* recursively. That is, whether it's locked more than once by the
469+
* current holder.
470+
* Note that this is inherently racy unless the calling thread is
471+
* holding the mutex.
464472
*
465473
* Parameters:
466474
* rmutex - Recursive mutex descriptor.
@@ -477,6 +485,8 @@ bool nxrmutex_is_recursive(FAR rmutex_t *rmutex);
477485
*
478486
* Description:
479487
* This function get the holder of the mutex referenced by 'mutex'.
488+
* Note that this is inherently racy unless the calling thread is
489+
* holding the mutex.
480490
*
481491
* Parameters:
482492
* rmutex - Rmutex descriptor.
@@ -493,6 +503,8 @@ int nxrmutex_get_holder(FAR rmutex_t *rmutex);
493503
* Description:
494504
* This function get the lock state the recursive mutex
495505
* referenced by 'rmutex'.
506+
* Note that this is inherently racy unless the calling thread is
507+
* holding the mutex.
496508
*
497509
* Parameters:
498510
* rmutex - Recursive mutex descriptor.

libs/libc/misc/lib_mutex.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ int nxmutex_destroy(FAR mutex_t *mutex)
165165
* Name: nxmutex_is_hold
166166
*
167167
* Description:
168-
* This function check whether the caller hold the mutex
168+
* This function check whether the calling thread hold the mutex
169169
* referenced by 'mutex'.
170170
*
171171
* Parameters:
@@ -185,6 +185,8 @@ bool nxmutex_is_hold(FAR mutex_t *mutex)
185185
*
186186
* Description:
187187
* This function get the holder of the mutex referenced by 'mutex'.
188+
* Note that this is inherently racy unless the calling thread is
189+
* holding the mutex.
188190
*
189191
* Parameters:
190192
* mutex - mutex descriptor.
@@ -203,6 +205,8 @@ int nxmutex_get_holder(FAR mutex_t *mutex)
203205
*
204206
* Description:
205207
* This function get the lock state the mutex referenced by 'mutex'.
208+
* Note that this is inherently racy unless the calling thread is
209+
* holding the mutex.
206210
*
207211
* Parameters:
208212
* mutex - mutex descriptor.
@@ -645,7 +649,7 @@ int nxrmutex_destroy(FAR rmutex_t *rmutex)
645649
* Name: nxrmutex_is_hold
646650
*
647651
* Description:
648-
* This function check whether the caller hold the recursive mutex
652+
* This function check whether the calling thread hold the recursive mutex
649653
* referenced by 'rmutex'.
650654
*
651655
* Parameters:
@@ -664,7 +668,11 @@ bool nxrmutex_is_hold(FAR rmutex_t *rmutex)
664668
* Name: nxrmutex_is_recursive
665669
*
666670
* Description:
667-
* This function check whether the recursive mutex is recursive
671+
* This function check whether the recursive mutex is currently held
672+
* recursively. That is, whether it's locked more than once by the
673+
* current holder.
674+
* Note that this is inherently racy unless the calling thread is
675+
* holding the mutex.
668676
*
669677
* Parameters:
670678
* rmutex - Recursive mutex descriptor.
@@ -684,6 +692,8 @@ bool nxrmutex_is_recursive(FAR rmutex_t *rmutex)
684692
*
685693
* Description:
686694
* This function get the holder of the mutex referenced by 'mutex'.
695+
* Note that this is inherently racy unless the calling thread is
696+
* holding the mutex.
687697
*
688698
* Parameters:
689699
* rmutex - Rmutex descriptor.
@@ -703,6 +713,8 @@ int nxrmutex_get_holder(FAR rmutex_t *rmutex)
703713
* Description:
704714
* This function get the lock state the recursive mutex
705715
* referenced by 'rmutex'.
716+
* Note that this is inherently racy unless the calling thread is
717+
* holding the mutex.
706718
*
707719
* Parameters:
708720
* rmutex - Recursive mutex descriptor.

0 commit comments

Comments
 (0)