summaryrefslogtreecommitdiffstats
path: root/cpukit/score/cpu/i386
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-05-08 10:11:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-05-08 13:02:40 +0200
commit11b05f11d4d6d61717e345d20f492977b95ab131 (patch)
tree5f5bd2a21ea205ea0700d44718de7fcac8234fe7 /cpukit/score/cpu/i386
parentdoc: Use @dfn for glossary terms (diff)
downloadrtems-11b05f11d4d6d61717e345d20f492977b95ab131.tar.bz2
score: Fix CPU context usage on SMP
We must not alter the is executing indicator in _CPU_Context_Initialize() since this would cause an invalid state during a self restart. The is executing indicator must be valid at creation time since otherwise _Thread_Kill_zombies() uses an undefined value for not started threads. This could result in a system life lock.
Diffstat (limited to '')
-rw-r--r--cpukit/score/cpu/i386/cpu_asm.S8
-rw-r--r--cpukit/score/cpu/i386/rtems/score/cpu.h23
2 files changed, 18 insertions, 13 deletions
diff --git a/cpukit/score/cpu/i386/cpu_asm.S b/cpukit/score/cpu/i386/cpu_asm.S
index cc08312f33..9b395678b8 100644
--- a/cpukit/score/cpu/i386/cpu_asm.S
+++ b/cpukit/score/cpu/i386/cpu_asm.S
@@ -58,24 +58,24 @@ SYM (_CPU_Context_switch):
movl edi,REG_EDI(eax) /* save destination register */
#ifdef RTEMS_SMP
- /* Indicate that this context is no longer executing */
+ /* The executing context no longer executes on this processor */
movb $0, I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET(eax)
#endif
movl HEIRCONTEXT_ARG(esp),eax /* eax = heir threads context */
-restore:
#ifdef RTEMS_SMP
- /* Wait for context to stop execution if necessary */
+ /* Wait for heir context to stop execution */
1:
movb I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET(eax), bl
testb bl, bl
jne 1b
- /* Indicate that this context is executing */
+ /* The heir context executes now on this processor */
movb $1, I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET(eax)
#endif
+restore:
pushl REG_EFLAGS(eax) /* push eflags */
popf /* restore eflags */
movl REG_ESP(eax),esp /* restore stack pointer */
diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h
index ba731b0666..2d1472d4df 100644
--- a/cpukit/score/cpu/i386/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/rtems/score/cpu.h
@@ -167,8 +167,20 @@ typedef struct {
(_context)->esp
#ifdef RTEMS_SMP
- #define _CPU_Context_Get_is_executing( _context ) \
- (_context)->is_executing
+ static inline bool _CPU_Context_Get_is_executing(
+ const Context_Control *context
+ )
+ {
+ return context->is_executing;
+ }
+
+ static inline void _CPU_Context_Set_is_executing(
+ Context_Control *context,
+ bool is_executing
+ )
+ {
+ context->is_executing = is_executing;
+ }
#endif
/*
@@ -454,12 +466,6 @@ uint32_t _CPU_ISR_Get_level( void );
*/
-#ifdef RTEMS_SMP
- #define _I386_Context_Initialize_is_executing( _the_context ) \
- (_the_context)->is_executing = false
-#else
- #define _I386_Context_Initialize_is_executing( _the_context )
-#endif
#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
_isr, _entry_point, _is_fp, _tls_area ) \
@@ -475,7 +481,6 @@ uint32_t _CPU_ISR_Get_level( void );
*((proc_ptr *)(_stack)) = (_entry_point); \
(_the_context)->ebp = (void *) 0; \
(_the_context)->esp = (void *) _stack; \
- _I386_Context_Initialize_is_executing( _the_context ); \
} while (0)
#define _CPU_Context_Restart_self( _the_context ) \