X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=execution.cc;h=3c6d0d7588dc2ff33984a94577b34de37bfdac2f;hb=dd34ddf490dd97c2c202092c8fa44064a07f8c4f;hp=17ea954a65570160ffccd1a42f247c95956b8fa2;hpb=b5d7d602016a4640c31b79ba9598dceefa778ab6;p=model-checker.git diff --git a/execution.cc b/execution.cc index 17ea954..3c6d0d7 100644 --- a/execution.cc +++ b/execution.cc @@ -65,7 +65,7 @@ ModelExecution::ModelExecution(ModelChecker *m, params(params), scheduler(scheduler), action_trace(), - thread_map(), + thread_map(2), /* We'll always need at least 2 threads */ obj_map(new HashTable()), condvar_waiters_map(), obj_thrd_map(), @@ -80,7 +80,7 @@ ModelExecution::ModelExecution(ModelChecker *m, { /* Initialize a model-checker thread, for special ModelActions */ model_thread = new Thread(get_next_id()); - thread_map.put(id_to_int(model_thread->get_id()), model_thread); + add_thread(model_thread); scheduler->register_engine(this); } @@ -88,7 +88,7 @@ ModelExecution::ModelExecution(ModelChecker *m, ModelExecution::~ModelExecution() { for (unsigned int i = 0; i < get_num_threads(); i++) - delete thread_map.get(i); + delete get_thread(int_to_id(i)); delete obj_map; @@ -2675,7 +2675,10 @@ void ModelExecution::print_summary() const */ void ModelExecution::add_thread(Thread *t) { - thread_map.put(id_to_int(t->get_id()), t); + unsigned int i = id_to_int(t->get_id()); + if (i >= thread_map.size()) + thread_map.resize(i + 1); + thread_map[i] = t; if (!t->is_model_thread()) scheduler->add_thread(t); } @@ -2687,7 +2690,10 @@ void ModelExecution::add_thread(Thread *t) */ Thread * ModelExecution::get_thread(thread_id_t tid) const { - return thread_map.get(id_to_int(tid)); + unsigned int i = id_to_int(tid); + if (i < thread_map.size()) + return thread_map[i]; + return NULL; } /**