summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzms123456 <[email protected]>2024-09-07 05:44:02 +0800
committerGitHub <[email protected]>2024-09-06 17:44:02 -0400
commit9631f04abefdea2341abe8cfe96cbabbdf432ab7 (patch)
tree8f7f4363540f8ea970cba0005d67714ef5ab8e64 /src
parent0c16568387db1b75690198862ceda7314b6a881c (diff)
[utest]add mutex_pi_tc
* add mutex_pi * fix assertion error when thread wakeup while waiting mutex
Diffstat (limited to 'src')
-rw-r--r--src/ipc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ipc.c b/src/ipc.c
index a1a9c1f2da..fd8e9c66bf 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -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);
/**