return swapcontext(&old->context, &new->context);
}
-int thread_yield(void)
-{
- struct thread *old, *next;
-
- DBG();
- old = thread_current();
- old->state = THREAD_READY;
- next = model->system_thread;
- return thread_swap(old, next);
-}
-
static void thread_dispose(struct thread *t)
{
DEBUG("completed thread %d\n", thread_current()->index);
while (!thread_system_next());
}
+/*
+ * User program API functions
+ */
int thread_create(struct thread *t, void (*start_routine), void *arg)
{
static int created = 1;
thread_yield();
}
+int thread_yield(void)
+{
+ struct thread *old, *next;
+
+ DBG();
+ old = thread_current();
+ old->state = THREAD_READY;
+ next = model->system_thread;
+ return thread_swap(old, next);
+}
+
struct thread *thread_current(void)
{
return model->scheduler->get_current_thread();
}
+/*
+ * Main system function
+ */
int main()
{
struct thread user_thread;