[utest]add mutex_pi_tc

* add mutex_pi
* fix assertion error when thread wakeup while waiting mutex
This commit is contained in:
zms123456
2024-09-06 17:44:02 -04:00
committed by GitHub
parent 0c16568387
commit 9631f04abe
3 changed files with 362 additions and 3 deletions
+8 -2
View File
@@ -1450,13 +1450,13 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
rt_spin_lock(&(mutex->spinlock));
if (thread->error == RT_EOK)
if (mutex->owner == thread)
{
/**
* get mutex successfully
* Note: assert to avoid an unexpected resume
*/
RT_ASSERT(mutex->owner == thread);
RT_ASSERT(thread->error == RT_EOK);
}
else
{
@@ -1468,6 +1468,12 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
/* get value first before calling to other APIs */
ret = thread->error;
/* unexpected resume */
if (ret == RT_EOK)
{
ret = -RT_EINTR;
}
rt_sched_lock(&slvl);
/**