Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

已更新 2025年4月

xSemaphoreGetMutexHolder

[信号量]

semphr. h

1TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );

必须在 FreeRTOSConfig.h 中将 INCLUDE_xSemaphoreGetMutexHolder 设置为 1, 此函数才可用。

返回保存函数参数指定的互斥锁的任务的句柄(若有)。

xSemaphoreGetMutexHolder () 可以可靠地用于确定调用任务是否 是互斥锁持有者,但如果由调用任务之外的任务持有互斥锁,则无法可靠地使用 xSemaphoreGetMutexHolder () 。这是因为 MUTEX 支架可能会 在调用该函数的调用任务与测试该函数返回值之间 更改。

configUSE_MUTEXES 必须在 FreeRTOSConfig.h 中设置为 1,xSemaphoreGetMutexHolder() 才可用。

参数:

  • xMutex

    正在查询的互斥体的句柄。

返回:

保存 xMutex 参数指定的互斥锁的任务的句柄。如果 在 xMutex 参数中传递的信号量不是互斥锁型信号量,或者如果互斥锁可用,但未被任何任务保存, 则返回 NULL。