From: Brian Norris <banorris@uci.edu>
Date: Tue, 24 Apr 2012 02:46:30 +0000 (-0700)
Subject: threads: don't make direct call into scheduler
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fe8423ca853f5d614e618fe49d37d0943d416809;p=cdsspec-compiler.git

threads: don't make direct call into scheduler

Since I need a ModelChecker::add_thread(Thread *) function anyway, I should
direct add_thread() calls through the model-checker framework rather than the
Scheduler class. This will make things a little cleaner and symmetric when I
add a remove_thread() function.
---

diff --git a/model.cc b/model.cc
index 1f13de7..f50b0f9 100644
--- a/model.cc
+++ b/model.cc
@@ -201,6 +201,7 @@ void ModelChecker::print_trace(void)
 int ModelChecker::add_thread(Thread *t)
 {
 	thread_map[t->get_id()] = t;
+	scheduler->add_thread(t);
 	return 0;
 }
 
diff --git a/threads.cc b/threads.cc
index 4c7ac41..3af7496 100644
--- a/threads.cc
+++ b/threads.cc
@@ -75,7 +75,6 @@ Thread::Thread(thrd_t *t, void (*func)(), void *a) {
 	state = THREAD_CREATED;
 	id = model->get_next_id();
 	*user_thread = id;
-	model->scheduler->add_thread(this);
 }
 
 Thread::Thread(thrd_t *t) {