+/*
+ * Return 1 if found next thread, 0 otherwise
+ */
+static int thread_system_next(void)
+{
+ struct thread *curr, *next;
+
+ curr = thread_current();
+ if (curr) {
+ if (curr->state == THREAD_READY)
+ model->scheduler->add_thread(curr);
+ else if (curr->state == THREAD_RUNNING)
+ /* Stopped while running; i.e., completed */
+ thread_dispose(curr);
+ else
+ DEBUG("ERROR: current thread in unexpected state??\n");