From: weiyu Date: Tue, 25 Aug 2020 22:14:15 +0000 (-0700) Subject: edits X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=7bba6b355f7b2250aed59de4b9d20f36c89a3eb4 edits --- diff --git a/libthreads.cc b/libthreads.cc index 5ff106c8..c06a9be2 100644 --- a/libthreads.cc +++ b/libthreads.cc @@ -28,7 +28,7 @@ int thrd_join(thrd_t t) /** A no-op, for now */ void thrd_yield(void) { - model->switch_to_master(new ModelAction(THREAD_YIELD, std::memory_order_seq_cst, thread_current(), VALUE_NONE)); + model->switch_thread(new ModelAction(THREAD_YIELD, std::memory_order_seq_cst, thread_current(), VALUE_NONE)); } thrd_t thrd_current(void) diff --git a/model.cc b/model.cc index 090743a4..d9671a30 100644 --- a/model.cc +++ b/model.cc @@ -346,7 +346,6 @@ uint64_t ModelChecker::switch_to_master(ModelAction *act) void ModelChecker::startRunExecution(Thread *old) { - if (params.traceminsize != 0 && execution->get_curr_seq_num() > checkfree) { checkfree += params.checkthreshold; @@ -390,12 +389,12 @@ Thread* ModelChecker::getNextThread() if (act && execution->is_enabled(thr) && !execution->check_action_enabled(act)) { scheduler->sleep(thr); } - - chooseThread(act, thr); + chooseThread(act, thr); } return nextThread; } +/* Swap back to system_context and terminate this execution */ void ModelChecker::finishRunExecution(Thread *old) { scheduler->set_current_thread(NULL); @@ -515,9 +514,9 @@ void ModelChecker::handleChosenThread(Thread *old) chosen_thread->set_pending(NULL); chosen_thread = NULL; // Allow this thread to stash the next pending action - if (should_terminate_execution()) - finishRunExecution(th); - else +// if (should_terminate_execution()) +// finishRunExecution(th); +// else startRunExecution(th); } else { /* Consume the next action for a Thread */ @@ -566,8 +565,6 @@ void ModelChecker::run() if (break_execution) break; - thread_chosen = false; - curr_thread_num = 1; startRunExecution(NULL); } while (!should_terminate_execution()); diff --git a/pthread.cc b/pthread.cc index b5fb7ce9..e453f1b2 100644 --- a/pthread.cc +++ b/pthread.cc @@ -24,10 +24,8 @@ int pthread_create(pthread_t *t, const pthread_attr_t * attr, struct pthread_params params = { start_routine, arg }; - ModelAction *act = new ModelAction(PTHREAD_CREATE, std::memory_order_seq_cst, t, (uint64_t)¶ms); - /* seq_cst is just a 'don't care' parameter */ - model->switch_to_master(act); + model->switch_to_master(new ModelAction(PTHREAD_CREATE, std::memory_order_seq_cst, t, (uint64_t)¶ms)); return 0; } @@ -54,7 +52,7 @@ int pthread_detach(pthread_t t) { /* Take care of both pthread_yield and c++ thread yield */ int sched_yield() { - model->switch_to_master(new ModelAction(THREAD_YIELD, std::memory_order_seq_cst, thread_current(), VALUE_NONE)); + model->switch_thread(new ModelAction(THREAD_YIELD, std::memory_order_seq_cst, thread_current(), VALUE_NONE)); return 0; } @@ -205,7 +203,7 @@ int pthread_cond_timedwait(pthread_cond_t *p_cond, cdsc::snapcondition_variable *v = execution->getCondMap()->get(p_cond); cdsc::snapmutex *m = execution->getMutexMap()->get(p_mutex); - model->switch_to_master(new ModelAction(ATOMIC_TIMEDWAIT, std::memory_order_seq_cst, v, (uint64_t) m)); + model->switch_thread(new ModelAction(ATOMIC_TIMEDWAIT, std::memory_order_seq_cst, v, (uint64_t) m)); m->lock(); // model_print("Timed_wait is called\n");