diff --git a/include/nuttx/mutex.h b/include/nuttx/mutex.h index 1ad8bfe4eff..6299fd35e31 100644 --- a/include/nuttx/mutex.h +++ b/include/nuttx/mutex.h @@ -392,6 +392,22 @@ int nxrmutex_destroy(FAR rmutex_t *rmutex); bool nxrmutex_is_hold(FAR rmutex_t *rmutex); +/**************************************************************************** + * Name: nxrmutex_is_recursive + * + * Description: + * This function check whether the recursive mutex is recursive + * + * Parameters: + * rmutex - Recursive mutex descriptor. + * + * Return Value: + * If rmutex has returned to True recursively, otherwise returns false. + * + ****************************************************************************/ + +bool nxrmutex_is_recursive(FAR rmutex_t *rmutex); + /**************************************************************************** * Name: nxrmutex_get_holder * diff --git a/libs/libc/misc/lib_mutex.c b/libs/libc/misc/lib_mutex.c index 3e3d8341f22..a00df061fe3 100644 --- a/libs/libc/misc/lib_mutex.c +++ b/libs/libc/misc/lib_mutex.c @@ -553,6 +553,25 @@ bool nxrmutex_is_hold(FAR rmutex_t *rmutex) return nxmutex_is_hold(&rmutex->mutex); } +/**************************************************************************** + * Name: nxrmutex_is_recursive + * + * Description: + * This function check whether the recursive mutex is recursive + * + * Parameters: + * rmutex - Recursive mutex descriptor. + * + * Return Value: + * If rmutex has returned to True recursively, otherwise returns false. + * + ****************************************************************************/ + +bool nxrmutex_is_recursive(FAR rmutex_t *rmutex) +{ + return rmutex->count > 1; +} + /**************************************************************************** * Name: nxrmutex_get_holder *