diff --git a/kernel/init.c b/kernel/init.c index a29807ac..2d374f52 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -93,6 +93,7 @@ int network_init(void) // Initialize lwIP modules tcpip_init(tcp_init_ok, NULL); + lwip_initialized = 0; while(!lwip_initialized) { reschedule(); } diff --git a/kernel/tasks.c b/kernel/tasks.c index 4101bcda..0613fc95 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -107,7 +107,7 @@ size_t get_idle_task(uint32_t id) #endif } -static void finish_task_switch(void) +static void finish_task_switch(uint32_t irq) { uint8_t prio; uint32_t core_id = CORE_ID; @@ -130,7 +130,8 @@ static void finish_task_switch(void) } spinlock_unlock(&runqueues[core_id].lock); - irq_enable(); + if (irq) + irq_enable(); } /** @brief Wakeup tasks which are waiting for a message from the current one @@ -388,7 +389,7 @@ int sys_fork(void) // Leave the function without releasing the locks // because the locks are already released // by the parent task! - finish_task_switch(); + finish_task_switch(1); return 0; } @@ -423,7 +424,7 @@ static int STDCALL kernel_entry(void* args) int ret; kernel_args_t* kernel_args = (kernel_args_t*) args; - finish_task_switch(); + finish_task_switch(1); if (BUILTIN_EXPECT(!kernel_args, 0)) return -EINVAL; @@ -679,7 +680,7 @@ static int STDCALL user_entry(void* arg) { int ret; - finish_task_switch(); + finish_task_switch(1); if (BUILTIN_EXPECT(!arg, 0)) return -EINVAL; @@ -1265,6 +1266,7 @@ get_task_out: //kprintf("schedule from %u to %u with prio %u on core %u\n", // orig_task->id, curr_task->id, (uint32_t)curr_task->prio, CORE_ID); switch_task(curr_task->id); + finish_task_switch(0); } }