From 38b59a6d3052654e356ae16b4a243c362312acce Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 2 May 2014 10:31:09 +0200 Subject: score: Implement forced thread migration The current implementation of task migration in RTEMS has some implications with respect to the interrupt latency. It is crucial to preserve the system invariant that a task can execute on at most one processor in the system at a time. This is accomplished with a boolean indicator in the task context. The processor architecture specific low-level task context switch code will mark that a task context is no longer executing and waits that the heir context stopped execution before it restores the heir context and resumes execution of the heir task. So there is one point in time in which a processor is without a task. This is essential to avoid cyclic dependencies in case multiple tasks migrate at once. Otherwise some supervising entity is necessary to prevent life-locks. Such a global supervisor would lead to scalability problems so this approach is not used. Currently the thread dispatch is performed with interrupts disabled. So in case the heir task is currently executing on another processor then this prolongs the time of disabled interrupts since one processor has to wait for another processor to make progress. It is difficult to avoid this issue with the interrupt latency since interrupts normally store the context of the interrupted task on its stack. In case a task is marked as not executing we must not use its task stack to store such an interrupt context. We cannot use the heir stack before it stopped execution on another processor. So if we enable interrupts during this transition we have to provide an alternative task independent stack for this time frame. This issue needs further investigation. --- cpukit/score/cpu/i386/cpu.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cpukit/score/cpu/i386/cpu.c') diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c index ba7501a246..38b84e6750 100644 --- a/cpukit/score/cpu/i386/cpu.c +++ b/cpukit/score/cpu/i386/cpu.c @@ -26,6 +26,24 @@ #include #include +#define I386_ASSERT_OFFSET(field, off) \ + RTEMS_STATIC_ASSERT( \ + offsetof(Context_Control, field) \ + == I386_CONTEXT_CONTROL_ ## off ## _OFFSET, \ + Context_Control_ ## field \ + ) + +I386_ASSERT_OFFSET(eflags, EFLAGS); +I386_ASSERT_OFFSET(esp, ESP); +I386_ASSERT_OFFSET(ebp, EBP); +I386_ASSERT_OFFSET(ebx, EBX); +I386_ASSERT_OFFSET(esi, ESI); +I386_ASSERT_OFFSET(edi, EDI); + +#ifdef RTEMS_SMP + I386_ASSERT_OFFSET(is_executing, IS_EXECUTING); +#endif + void _CPU_Initialize(void) { #if CPU_HARDWARE_FP -- cgit v1.2.3