avoid a task migration during the calculation of the current task

=> temporary clearing the IF flag
This commit is contained in:
Stefan Lankes 2011-07-20 08:24:24 +02:00
parent dfa928de78
commit 20c944b099
4 changed files with 17 additions and 7 deletions

View file

@ -187,8 +187,6 @@ typedef struct {
} dest;
} __attribute__ ((packed)) ioapic_route_t;
#define smp_id apic_cpu_id
int apic_init(void);
void apic_eoi(void);
uint32_t apic_cpu_id(void);

View file

@ -99,6 +99,10 @@ struct state {
unsigned int ss;
};
uint32_t apic_cpu_id(void);
#define smp_id apic_cpu_id
#ifdef __cplusplus
}
#endif

View file

@ -22,6 +22,7 @@
#include <metalsvm/config.h>
#include <asm/stddef.h>
#include <asm/irqflags.h>
#ifdef __cplusplus
extern "C" {
@ -37,10 +38,17 @@ typedef unsigned int tid_t;
#define DEFINE_PER_CORE(type, name, def_value) type name = def_value;
#define CORE_ID 0
#else
#define per_core(name) name[smp_id()].var
#define per_core(name) __get_percore_##name()
#define DECLARE_PER_CORE(type, name) \
typedef struct { type var __attribute__ ((aligned (CACHE_LINE))); } aligned_##name;\
extern aligned_##name name[MAX_CORES];
extern aligned_##name name[MAX_CORES];\
inline static type __get_percore_##name(void) {\
type ret; \
uint32_t flags = irq_nested_disable(); \
ret = name[smp_id()].var; \
irq_nested_enable(flags);\
return ret; \
}
#define DEFINE_PER_CORE(type, name, def_value) \
aligned_##name name[MAX_CORES] = {[0 ... MAX_CORES-1] = {def_value}};
#define CORE_ID smp_id()

View file

@ -68,7 +68,7 @@ int multitasking_init(void) {
memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS);
task_table[0].pgd = get_boot_pgd();
task_table[0].flags = TASK_DEFAULT_FLAGS;
per_core(current_task) = task_table+0;
current_task[0].var = task_table+0;
return 0;
}
@ -763,7 +763,7 @@ void scheduler(void)
if (curr_task->status == TASK_RUNNING)
curr_task->status = TASK_READY;
task_table[new_id].status = TASK_RUNNING;
per_core(current_task) = task_table+new_id;
current_task[CORE_ID].var = task_table+new_id;
goto get_task_out;
}
@ -776,7 +776,7 @@ void scheduler(void)
* we switch to the idle task, if the current task terminates
* and no other is ready
*/
per_core(current_task) = task_table+smp_id();
current_task[CORE_ID].var = task_table+CORE_ID;
get_task_out:
//kprintf("schedule %d on core %d\n", per_core(current_task)->id, smp_id());