summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoraozima <[email protected]>2020-08-14 16:29:11 +0800
committeraozima <[email protected]>2020-08-14 16:29:11 +0800
commit79fd12842beeee5a653ba6f4bc2f08b21be7697a (patch)
tree841402b8580e1820179cc79f47f74bd649d49403 /src
parent6bf76a375c53c1de3f1a4b1d0f7fc6506833f6dd (diff)
parent5b94c1482e8e63f68ad2437cacf2e60e6737626a (diff)
Merge branch 'master' into gitee_master
Diffstat (limited to 'src')
-rw-r--r--src/ipc.c26
-rw-r--r--src/kservice.c13
-rw-r--r--src/scheduler.c25
-rw-r--r--src/timer.c5
4 files changed, 48 insertions, 21 deletions
diff --git a/src/ipc.c b/src/ipc.c
index 8e8c4db842..5646fc7f40 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -34,6 +34,8 @@
* 2013-09-14 Grissiom add an option check in rt_event_recv
* 2018-10-02 Bernard add 64bit support for mailbox
* 2019-09-16 tyx add send wait support for message queue
+ * 2020-07-29 Meco Man fix thread->event_set/event_info when received an
+ event without pending
*/
#include <rtthread.h>
@@ -117,6 +119,9 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list,
rt_list_insert_before(list, &(thread->tlist));
}
break;
+
+ default:
+ break;
}
return RT_EOK;
@@ -685,7 +690,9 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
}
else
{
+#ifdef RT_USING_SIGNALS
__again:
+#endif /* end of 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.
*/
@@ -754,8 +761,10 @@ __again:
if (thread->error != RT_EOK)
{
+#ifdef RT_USING_SIGNALS
/* interrupt by signal, try it again */
if (thread->error == -RT_EINTR) goto __again;
+#endif /* end of RT_USING_SIGNALS */
/* return error */
return thread->error;
@@ -1080,6 +1089,13 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
status = RT_EOK;
}
}
+ else
+ {
+ /* enable interrupt */
+ rt_hw_interrupt_enable(level);
+
+ return -RT_EINVAL;
+ }
/* move node to the next */
n = n->next;
@@ -1177,7 +1193,11 @@ rt_err_t rt_event_recv(rt_event_t event,
/* set received event */
if (recved)
*recved = (event->set & set);
-
+
+ /* fill thread event info */
+ thread->event_set = (event->set & set);
+ thread->event_info = option;
+
/* received event */
if (option & RT_EVENT_FLAG_CLEAR)
event->set &= ~set;
@@ -1186,10 +1206,10 @@ rt_err_t rt_event_recv(rt_event_t event,
{
/* no waiting */
thread->error = -RT_ETIMEOUT;
-
+
/* enable interrupt */
rt_hw_interrupt_enable(level);
-
+
return -RT_ETIMEOUT;
}
else
diff --git a/src/kservice.c b/src/kservice.c
index 1705ce5283..7caf43ce28 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -456,7 +456,10 @@ RTM_EXPORT(rt_strncmp);
rt_int32_t rt_strcmp(const char *cs, const char *ct)
{
while (*cs && *cs == *ct)
- cs++, ct++;
+ {
+ cs++;
+ ct++;
+ }
return (*cs - *ct);
}
@@ -543,7 +546,7 @@ void rt_show_version(void)
RTM_EXPORT(rt_show_version);
/* private function */
-#define isdigit(c) ((unsigned)((c) - '0') < 10)
+#define _ISDIGIT(c) ((unsigned)((c) - '0') < 10)
#ifdef RT_PRINTF_LONGLONG
rt_inline int divide(long long *n, int base)
@@ -588,7 +591,7 @@ rt_inline int divide(long *n, int base)
rt_inline int skip_atoi(const char **s)
{
register int i = 0;
- while (isdigit(**s))
+ while (_ISDIGIT(**s))
i = i * 10 + *((*s)++) - '0';
return i;
@@ -834,7 +837,7 @@ rt_int32_t rt_vsnprintf(char *buf,
/* get field width */
field_width = -1;
- if (isdigit(*fmt)) field_width = skip_atoi(&fmt);
+ if (_ISDIGIT(*fmt)) field_width = skip_atoi(&fmt);
else if (*fmt == '*')
{
++ fmt;
@@ -853,7 +856,7 @@ rt_int32_t rt_vsnprintf(char *buf,
if (*fmt == '.')
{
++ fmt;
- if (isdigit(*fmt)) precision = skip_atoi(&fmt);
+ if (_ISDIGIT(*fmt)) precision = skip_atoi(&fmt);
else if (*fmt == '*')
{
++ fmt;
diff --git a/src/scheduler.c b/src/scheduler.c
index 6baaa9627a..0c1bf1e506 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -33,10 +33,6 @@
#include <rtthread.h>
#include <rthw.h>
-#ifdef RT_USING_SMP
-rt_hw_spinlock_t _rt_critical_lock;
-#endif /*RT_USING_SMP*/
-
rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
rt_uint32_t rt_thread_ready_priority_group;
#if RT_THREAD_PRIORITY_MAX > 32
@@ -851,7 +847,7 @@ void rt_enter_critical(void)
if (!current_thread)
{
rt_hw_local_irq_enable(level);
- return ;
+ return;
}
/*
@@ -859,12 +855,15 @@ void rt_enter_critical(void)
* enough and does not check here
*/
- /* lock scheduler for all cpus */
- if (current_thread->critical_lock_nest == 0)
{
- rt_hw_spin_lock(&_rt_critical_lock);
+ register rt_uint16_t lock_nest = current_thread->cpus_lock_nest;
+ current_thread->cpus_lock_nest++;
+ if (lock_nest == 0)
+ {
+ current_thread->scheduler_lock_nest ++;
+ rt_hw_spin_lock(&_cpus_lock);
+ }
}
-
/* critical for local cpu */
current_thread->critical_lock_nest ++;
@@ -910,16 +909,18 @@ void rt_exit_critical(void)
if (!current_thread)
{
rt_hw_local_irq_enable(level);
- return ;
+ return;
}
current_thread->scheduler_lock_nest --;
current_thread->critical_lock_nest --;
- if (current_thread->critical_lock_nest == 0)
+ current_thread->cpus_lock_nest--;
+ if (current_thread->cpus_lock_nest == 0)
{
- rt_hw_spin_unlock(&_rt_critical_lock);
+ current_thread->scheduler_lock_nest --;
+ rt_hw_spin_unlock(&_cpus_lock);
}
if (current_thread->scheduler_lock_nest <= 0)
diff --git a/src/timer.c b/src/timer.c
index 28a5a9e494..4d12c7ec78 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -500,7 +500,10 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
/*timer is stop*/
*(rt_tick_t *)arg = RT_TIMER_FLAG_DEACTIVATED;
}
- break;
+ break;
+
+ default:
+ break;
}
return RT_EOK;