Fix bug with code to get rid of main
authorroot <root@plrg-1.ics.uci.edu>
Sat, 7 Dec 2019 04:31:35 +0000 (20:31 -0800)
committerroot <root@plrg-1.ics.uci.edu>
Sat, 7 Dec 2019 04:31:35 +0000 (20:31 -0800)
model.cc
model.h
threads-model.h
threads.cc

index 52dd16f75cb7baf07fca1f0c31c66815d629a665..d6e5ed24e76108f89c37c1c7d9269978bb3f0460 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -39,9 +39,9 @@ ModelChecker::ModelChecker() :
        inspect_plugin(NULL)
 {
        model_print("C11Tester\n"
-                                "Copyright (c) 2013 and 2019 Regents of the University of California. All rights reserved.\n"
-                                "Distributed under the GPLv2\n"
-                                "Written by Weiyu Luo, Brian Norris, and Brian Demsky\n\n");
+                                                       "Copyright (c) 2013 and 2019 Regents of the University of California. All rights reserved.\n"
+                                                       "Distributed under the GPLv2\n"
+                                                       "Written by Weiyu Luo, Brian Norris, and Brian Demsky\n\n");
        memset(&stats,0,sizeof(struct execution_stats));
        init_thread = new Thread(execution->get_next_id(), (thrd_t *) model_malloc(sizeof(thrd_t)), &placeholder, NULL, NULL);
 #ifdef TLS
@@ -358,6 +358,7 @@ void ModelChecker::startChecker() {
        startExecution(get_system_context(), runChecker);
        snapshot_stack_init();
        snapshot_record(0);
+       initMainThread();
 }
 
 bool ModelChecker::should_terminate_execution()
@@ -386,12 +387,6 @@ void ModelChecker::do_restart()
        execution_number = 1;
 }
 
-void ModelChecker::startMainThread() {
-       init_thread->set_state(THREAD_RUNNING);
-       scheduler->set_current_thread(init_thread);
-       main_thread_startup();
-}
-
 /** @brief Run ModelChecker for the user program */
 void ModelChecker::run()
 {
diff --git a/model.h b/model.h
index 882ca069b32a9d8d7903805bba0986daa96d9f3e..ea526f7499bff4e919385fa9fda5d31f2d207eec 100644 (file)
--- a/model.h
+++ b/model.h
@@ -63,7 +63,6 @@ public:
        model_params params;
        void add_trace_analysis(TraceAnalysis *a) {     trace_analyses.push_back(a); }
        void set_inspect_plugin(TraceAnalysis *a) {     inspect_plugin=a;       }
-       void startMainThread();
        void startChecker();
        Thread * getInitThread() {return init_thread;}
        Scheduler * getScheduler() {return scheduler;}
index f2efd6c0a75f962600b820222b2cb62ffb974ff4..c6078200f5911f5bf3dd78f80125b881683e1a0e 100644 (file)
@@ -191,7 +191,7 @@ void tlsdestructor(void *v);
 
 Thread * thread_current();
 void thread_startup();
-void main_thread_startup();
+void initMainThread();
 
 static inline thread_id_t thrd_to_id(thrd_t t)
 {
index 8ee3bf975e732d7c943e512005c2dfd9eb218118..17b76863a62be4943ef07fc22d5e7df5bf6e83c7 100644 (file)
@@ -65,15 +65,10 @@ void modelexit() {
 }
 #endif
 
-void main_thread_startup() {
-#ifdef TLS
+void initMainThread() {
        atexit(modelexit);
        Thread * curr_thread = thread_current();
-
-       /* Add dummy "start" action, just to create a first clock vector */
        model->switch_to_master(new ModelAction(THREAD_START, std::memory_order_seq_cst, curr_thread));
-#endif
-       thread_startup();
 }
 
 /**
@@ -293,10 +288,7 @@ int Thread::create_context()
        context.uc_stack.ss_flags = 0;
        context.uc_link = model->get_system_context();
 #ifdef TLS
-       if (model != NULL)
-               makecontext(&context, setup_context, 0);
-       else
-               makecontext(&context, main_thread_startup, 0);
+       makecontext(&context, setup_context, 0);
 #else
        makecontext(&context, thread_startup, 0);
 #endif