From e57dd436704ed24dc97c7fea2fbb59e26ae90ec2 Mon Sep 17 00:00:00 2001
From: Brian Norris <banorris@uci.edu>
Date: Mon, 23 Apr 2012 17:12:01 -0700
Subject: [PATCH] threads: prepare system to loop over many executions

---
 model.cc   |  5 +++++
 model.h    |  2 ++
 threads.cc | 13 ++++++++-----
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/model.cc b/model.cc
index 773d723..afe159e 100644
--- a/model.cc
+++ b/model.cc
@@ -93,6 +93,11 @@ thread_id_t ModelChecker::advance_backtracking_state()
 	return get_next_replay_thread();
 }
 
+bool ModelChecker::next_execution()
+{
+	return false;
+}
+
 ModelAction *ModelChecker::get_last_conflict(ModelAction *act)
 {
 	void *loc = act->get_location();
diff --git a/model.h b/model.h
index 2a4082b..ccaeda2 100644
--- a/model.h
+++ b/model.h
@@ -84,6 +84,8 @@ public:
 	void assign_id(Thread *t);
 
 	int switch_to_master(ModelAction *act);
+
+	bool next_execution();
 private:
 	int used_thread_id;
 
diff --git a/threads.cc b/threads.cc
index 13be391..830ea1a 100644
--- a/threads.cc
+++ b/threads.cc
@@ -138,13 +138,16 @@ int main()
 
 	th = new Thread(&main_thread);
 
-	/* Start user program */
-	thrd_create(&user_thread, &user_main, NULL);
+	do {
+		/* Start user program */
+		thrd_create(&user_thread, &user_main, NULL);
 
-	/* Wait for all threads to complete */
-	thread_wait_finish();
+		/* Wait for all threads to complete */
+		thread_wait_finish();
+
+		model->print_trace();
+	} while (model->next_execution());
 
-	model->print_trace();
 	delete th;
 	delete model;
 
-- 
2.34.1