X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=model.cc;h=3716d78838ba26ab694ef6faca6d66aa283b1b04;hb=f414baab33bc07147613258c33798cc226bc5425;hp=142ae3efdfab1bf0812350a5fc89d37ea45c21b9;hpb=551ed6f7408e5376b3ea355997e378a1f2387e69;p=c11tester.git diff --git a/model.cc b/model.cc index 142ae3ef..3716d788 100644 --- a/model.cc +++ b/model.cc @@ -85,7 +85,7 @@ Thread * ModelChecker::schedule_next_thread() return t; } -/* +/** * get_next_replay_thread() - Choose the next thread in the replay sequence * * If we've reached the 'diverge' point, then we pick a thread from the @@ -154,7 +154,7 @@ ModelAction * ModelChecker::get_last_conflict(ModelAction *act) action_list_t::reverse_iterator rit; for (rit = action_trace->rbegin(); rit != action_trace->rend(); rit++) { ModelAction *prev = *rit; - if (act->is_dependent(prev)) + if (act->is_synchronizing(prev)) return prev; } return NULL; @@ -211,8 +211,15 @@ void ModelChecker::check_current_action(void) return; } - /* TODO: if get_last_action() is NULL, sync with parent thread */ - curr = node_stack->explore_action(curr, get_last_action(curr->get_tid())); + curr = node_stack->explore_action(curr); + curr->create_cv(get_parent_action(curr->get_tid())); + + /* Assign 'creation' parent */ + if (curr->get_type() == THREAD_CREATE) { + Thread *th = (Thread *)curr->get_location(); + th->set_creation(curr); + } + nextThread = get_next_replay_thread(); currnode = curr->get_node(); @@ -246,11 +253,19 @@ ModelAction * ModelChecker::get_last_action(thread_id_t tid) return (*thrd_last_action)[id_to_int(tid)]; } +ModelAction * ModelChecker::get_parent_action(thread_id_t tid) +{ + ModelAction *parent = get_last_action(tid); + if (!parent) + parent = get_thread(tid)->get_creation(); + return parent; +} + void ModelChecker::print_summary(void) { printf("\n"); printf("Number of executions: %d\n", num_executions); - printf("Total nodes created: %d\n", Node::get_total_nodes()); + printf("Total nodes created: %d\n", node_stack->get_total_nodes()); scheduler->print();