threads: set current thread to NULL in the scheduler
The scheduler may attempt to wake up the reaper thread and fail to
put it in ready queue when it was the the last one to execute and is
still considered "current".
@@ -633,6 +633,7 @@ int threads_schedule(unsigned int n, cpu_context_t *context, void *arg)
hal_spinlockSet(&threads_common.spinlock);
current = threads_common.current[hal_cpuGetID()];
+ threads_common.current[hal_cpuGetID()] = NULL;
/* Save current thread context */
if (current != NULL) {
