summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorthewon86 <[email protected]>2022-01-24 16:52:26 +0800
committerguo <[email protected]>2022-01-25 13:58:33 +0800
commit4db9cfbebe6d66f31d3a851fde82fd20318bfd05 (patch)
treeeb96cdfb51be75062845a0245d50f85b8b24a4e2 /src
parent3e59cfd70e5bfd9c95ac98a096432b1e9e2d185e (diff)
return thread error when resumed by signal
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ipc.c9
-rw-r--r--src/thread.c11
2 files changed, 10 insertions, 10 deletions
diff --git a/src/ipc.c b/src/ipc.c
index aea149a67a..5d4a2d018f 100755
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -40,6 +40,7 @@
* 2021-01-03 Meco Man implement rt_mb_urgent()
* 2021-05-30 Meco Man implement rt_mutex_trytake()
* 2022-01-07 Gabriel Moving __on_rt_xxxxx_hook to ipc.c
+ * 2022-01-24 THEWON let rt_mutex_take return thread->error when using signal
*/
#include <rtthread.h>
@@ -947,9 +948,6 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
}
else
{
-#ifdef RT_USING_SIGNALS
-__again:
-#endif /* RT_USING_SIGNALS */
/* The value of mutex is 1 in initial status. Therefore, if the
* value is great than 0, it indicates the mutex is avaible.
*/
@@ -1026,11 +1024,6 @@ __again:
if (thread->error != RT_EOK)
{
-#ifdef RT_USING_SIGNALS
- /* interrupt by signal, try it again */
- if (thread->error == -RT_EINTR) goto __again;
-#endif /* RT_USING_SIGNALS */
-
/* return error */
return thread->error;
}
diff --git a/src/thread.c b/src/thread.c
index bf1f2482a9..30208f1dd1 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -30,6 +30,7 @@
* 2021-11-15 THEWON Remove duplicate work between idle and _thread_exit
* 2021-12-27 Meco Man remove .init_priority
* 2022-01-07 Gabriel Moving __on_rt_xxxxx_hook to thread.c
+ * 2022-01-24 THEWON let rt_thread_sleep return thread->error when using signal
*/
#include <rthw.h>
@@ -566,6 +567,9 @@ rt_err_t rt_thread_sleep(rt_tick_t tick)
/* disable interrupt */
temp = rt_hw_interrupt_disable();
+ /* reset thread error */
+ thread->error = RT_EOK;
+
/* suspend thread */
rt_thread_suspend(thread);
@@ -582,7 +586,7 @@ rt_err_t rt_thread_sleep(rt_tick_t tick)
if (thread->error == -RT_ETIMEOUT)
thread->error = RT_EOK;
- return RT_EOK;
+ return thread->error;
}
/**
@@ -625,6 +629,9 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
/* disable interrupt */
level = rt_hw_interrupt_disable();
+ /* reset thread error */
+ thread->error = RT_EOK;
+
cur_tick = rt_tick_get();
if (cur_tick - *tick < inc_tick)
{
@@ -657,7 +664,7 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
rt_hw_interrupt_enable(level);
}
- return RT_EOK;
+ return thread->error;
}
RTM_EXPORT(rt_thread_delay_until);