fix wrong initialization of current_task

This commit is contained in:
Stefan Lankes 2011-07-30 17:36:21 +02:00
parent fba32ec692
commit f76f4ac70d

View file

@ -42,16 +42,17 @@
#include <asm/apic.h>
#include <asm/elf.h>
DEFINE_PER_CORE(task_t*, current_task, NULL);
/** @brief Array of task structures
*
* A task's id will be its position in this array.
*/
static task_t task_table[MAX_TASKS] = {[0 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), \
SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}};
static task_t task_table[MAX_TASKS] = { \
[0] = {0, TASK_RUNNING, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}};
static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT;
DEFINE_PER_CORE(task_t*, current_task, task_table+0);
/** @brief helper function for the assembly code to determine the current task
* @return Pointer to the task_t structure of current task
*/
@ -60,15 +61,11 @@ task_t* get_current_task(void) {
}
int multitasking_init(void) {
if (task_table[0].status == TASK_INVALID) {
task_table[0].id = 0;
task_table[0].status = TASK_RUNNING;
atomic_int32_set(&task_table[0].user_usage, 0);
if (BUILTIN_EXPECT(task_table[0].status == TASK_RUNNING, 1)) {
mailbox_wait_msg_init(&task_table[0].inbox);
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;
return 0;
}