From: Brian Norris <banorris@uci.edu>
Date: Mon, 23 Apr 2012 06:14:40 +0000 (-0700)
Subject: schedule: print debug info
X-Git-Tag: pldi2013~524
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5e2338d51de26e3ea875587f62b095c5d0111ae2;p=model-checker.git

schedule: print debug info
---

diff --git a/schedule.cc b/schedule.cc
index 13b640c..2498347 100644
--- a/schedule.cc
+++ b/schedule.cc
@@ -13,6 +13,8 @@ Thread *Scheduler::next_thread(void)
 {
 	Thread *t = model->schedule_next_thread();
 
+	print();
+
 	if (t != NULL) {
 		readyList.remove(t);
 		return t;
@@ -30,3 +32,16 @@ Thread *Scheduler::get_current_thread(void)
 {
 	return current;
 }
+
+void Scheduler::print()
+{
+	if (current)
+		printf("Current thread: %d\n", current->get_id());
+	else
+		printf("No current thread\n");
+	printf("# Threads in ready list: %ld\n", readyList.size());
+
+	std::list<Thread *>::iterator it;
+	for (it = readyList.begin(); it != readyList.end(); it++)
+		printf("In ready list: thread %d\n", (*it)->get_id());
+}
diff --git a/schedule.h b/schedule.h
index aa50ac3..86e4e40 100644
--- a/schedule.h
+++ b/schedule.h
@@ -11,6 +11,7 @@ public:
 	void add_thread(Thread *t);
 	Thread * next_thread(void);
 	Thread * get_current_thread(void);
+	void print();
 private:
 	std::list<Thread *> readyList;
 	Thread *current;