1.互斥锁添加volatile,防止被编译优化。

This commit is contained in:
MacRsh
2023-08-30 00:41:08 +08:00
parent 8bd8d71e67
commit 8695031cb6
2 changed files with 2 additions and 2 deletions

View File

@@ -77,7 +77,7 @@ void mr_object_rename(mr_object_t object, char *name);
void mr_mutex_init(mr_mutex_t mutex); void mr_mutex_init(mr_mutex_t mutex);
mr_err_t mr_mutex_take(mr_mutex_t mutex, void *owner); mr_err_t mr_mutex_take(mr_mutex_t mutex, void *owner);
mr_err_t mr_mutex_release(mr_mutex_t mutex, void *owner); mr_err_t mr_mutex_release(mr_mutex_t mutex, void *owner);
void *mr_mutex_get_owner(mr_mutex_t mutex); volatile void *mr_mutex_get_owner(mr_mutex_t mutex);
/** @} */ /** @} */
/** /**

View File

@@ -319,7 +319,7 @@ mr_err_t mr_mutex_release(mr_mutex_t mutex, void *owner)
* *
* @return A handle to the owner of the mutex, or MR_NULL if without owner. * @return A handle to the owner of the mutex, or MR_NULL if without owner.
*/ */
void *mr_mutex_get_owner(mr_mutex_t mutex) volatile void *mr_mutex_get_owner(mr_mutex_t mutex)
{ {
MR_ASSERT(mutex != MR_NULL); MR_ASSERT(mutex != MR_NULL);