summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbernard <[email protected]>2014-09-11 12:55:18 +0800
committerbernard <[email protected]>2014-09-11 12:55:18 +0800
commit3b5c2e2f9fe85e160c0184a2cc107a6925c8746b (patch)
tree12e276153e514a91898696f104b82b1b49d46773 /src
parent1f3ea02c5ace84d848a03fb014a664bdf586a07d (diff)
parent0ad7359b03158eb17d1cb3a62c7fde3d528a8ecc (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'src')
-rw-r--r--src/idle.c18
-rw-r--r--src/module.h2
2 files changed, 17 insertions, 3 deletions
diff --git a/src/idle.c b/src/idle.c
index ab0c992212..867af87612 100644
--- a/src/idle.c
+++ b/src/idle.c
@@ -61,6 +61,20 @@ void rt_thread_idle_sethook(void (*hook)(void))
}
#endif
+/* Return whether there is defunctional thread to be deleted. */
+rt_inline int _has_defunct_thread(void)
+{
+ /* The rt_list_isempty has prototype of "int rt_list_isempty(const rt_list_t *l)".
+ * So the compiler has a good reason that the rt_thread_defunct list does
+ * not change within rt_thread_idle_excute thus optimize the "while" loop
+ * into a "if".
+ *
+ * So add the volatile qualifier here. */
+ const volatile rt_list_t *l = (const volatile rt_list_t*)&rt_thread_defunct;
+
+ return l->next != l;
+}
+
/**
* @ingroup Thread
*
@@ -70,7 +84,7 @@ void rt_thread_idle_excute(void)
{
/* Loop until there is no dead thread. So one call to rt_thread_idle_excute
* will do all the cleanups. */
- while (!rt_list_isempty(&rt_thread_defunct))
+ while (_has_defunct_thread())
{
rt_base_t lock;
rt_thread_t thread;
@@ -83,7 +97,7 @@ void rt_thread_idle_excute(void)
lock = rt_hw_interrupt_disable();
/* re-check whether list is empty */
- if (!rt_list_isempty(&rt_thread_defunct))
+ if (_has_defunct_thread())
{
/* get defunct thread */
thread = rt_list_entry(rt_thread_defunct.next,
diff --git a/src/module.h b/src/module.h
index d2d4c4fcc8..3c45c96d02 100644
--- a/src/module.h
+++ b/src/module.h
@@ -239,7 +239,7 @@ typedef struct
#define SHT_DYNAMIC 6 /* dynamic section */
#define SHT_NOTE 7 /* note section */
#define SHT_NOBITS 8 /* no space section */
-#define SHT_REL 9 /* relation section without addends */
+#define SHT_REL 9 /* relocation section without addends */
#define SHT_SHLIB 10 /* reserved - purpose unknown */
#define SHT_DYNSYM 11 /* dynamic symbol table section */
#define SHT_NUM 12 /* number of section types */