Schedule() in thread.c takes the current running thread and the next thread in the ready list, and does an ASSERT that the next thread is a thread (is_thread(t) checks that t != NULL and that t->magic == THREAD_MAGIC). I'm currently getting this error:
List<>
I'm currently implementing timer_sleep so that it doesn't do busy waiting. Here is my timer_sleep function:
Kernel PANIC at ../../threads/thread.c:563 in schedule(): assertion 'is_thread(next)' failed.
And my timer_interrupt:
void
timer_sleep (int64_t ticks)
{
if (ticks > 0)
{
ASSERT (intr_get_level () == INTR_ON);
enum intr_level old_level;
old_level = intr_disable ();
struct thread *current_thread;
current_thread = thread_current();
int64_t wake_tick = timer_ticks() + ticks;
current_thread->wake_tick = wake_tick;
list_insert_ordered (&sleep_list, ¤t_thread->timer_elem, cmp_wake_ticks, NULL);
thread_block();
intr_set_level(old_level);
}
}
The only place where anything is being added to the ready_list is in thread_unblock, which also does an ASSERT is_thread, so I'm not sure where something that isn't a thread would ever be added to the ready list. I've not made any other changes to the base code other than adding the timer_elem to thread.h and the thread cmp_wake_ticks function.