From 10a01d4e17bdc2424dbc67a7f70c1f04e76e812d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 6 Dec 2019 20:31:35 -0800 Subject: [PATCH] Fix bug with code to get rid of main --- model.cc | 13 ++++--------- model.h | 1 - threads-model.h | 2 +- threads.cc | 12 ++---------- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/model.cc b/model.cc index 52dd16f7..d6e5ed24 100644 --- 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 882ca069..ea526f74 100644 --- 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;} diff --git a/threads-model.h b/threads-model.h index f2efd6c0..c6078200 100644 --- a/threads-model.h +++ b/threads-model.h @@ -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) { diff --git a/threads.cc b/threads.cc index 8ee3bf97..17b76863 100644 --- a/threads.cc +++ b/threads.cc @@ -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 -- 2.34.1