projects
/
model-checker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9cd5479
)
libthreads: separate private functions from user interface
author
Brian Norris
<banorris@uci.edu>
Tue, 13 Mar 2012 05:28:14 +0000
(22:28 -0700)
committer
Brian Norris
<banorris@uci.edu>
Tue, 13 Mar 2012 05:28:14 +0000
(22:28 -0700)
libthreads.c
patch
|
blob
|
history
diff --git
a/libthreads.c
b/libthreads.c
index 4233c0e306bdd94d8be557f58835c3be89eb20de..6a549d412893daf7b896d72460a64c158af61581 100644
(file)
--- a/
libthreads.c
+++ b/
libthreads.c
@@
-55,17
+55,6
@@
static int thread_swap(struct thread *old, struct thread *new)
return swapcontext(&old->context, &new->context);
}
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);
static void thread_dispose(struct thread *t)
{
DEBUG("completed thread %d\n", thread_current()->index);
@@
-107,6
+96,9
@@
static void thread_wait_finish(void)
while (!thread_system_next());
}
while (!thread_system_next());
}
+/*
+ * User program API functions
+ */
int thread_create(struct thread *t, void (*start_routine), void *arg)
{
static int created = 1;
int thread_create(struct thread *t, void (*start_routine), void *arg)
{
static int created = 1;
@@
-138,11
+130,25
@@
void thread_join(struct thread *t)
thread_yield();
}
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();
}
struct thread *thread_current(void)
{
return model->scheduler->get_current_thread();
}
+/*
+ * Main system function
+ */
int main()
{
struct thread user_thread;
int main()
{
struct thread user_thread;