X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=waitobj.cc;h=dc422be7804e0a245130b1ff0b3a93c511931e75;hp=692f0203fb2e1577c4b49efeefc78a64b4aefabc;hb=7742256df627848c1c375f979f5369a45c92057b;hpb=2ddb5d2c8170fe40d0f056d86e98f22c87c8c722 diff --git a/waitobj.cc b/waitobj.cc index 692f0203..dc422be7 100644 --- a/waitobj.cc +++ b/waitobj.cc @@ -2,6 +2,8 @@ #include "threads-model.h" #include "funcnode.h" +#define COUNTER_THRESHOLD 1000 + WaitObj::WaitObj(thread_id_t tid) : tid(tid), waiting_for(32), @@ -13,10 +15,10 @@ WaitObj::WaitObj(thread_id_t tid) : WaitObj::~WaitObj() { - for (uint i = 0; i < thrd_dist_maps.size(); i++) + for (uint i = 0;i < thrd_dist_maps.size();i++) delete thrd_dist_maps[i]; - for (uint i = 0; i < thrd_target_nodes.size(); i++) + for (uint i = 0;i < thrd_target_nodes.size();i++) delete thrd_target_nodes[i]; } @@ -105,7 +107,7 @@ dist_map_t * WaitObj::getDistMap(thread_id_t tid) if (old_size <= thread_id) { thrd_dist_maps.resize(thread_id + 1); - for (int i = old_size; i < thread_id + 1; i++) { + for (int i = old_size;i < thread_id + 1;i++) { thrd_dist_maps[i] = new dist_map_t(16); } } @@ -120,7 +122,7 @@ node_set_t * WaitObj::getTargetNodes(thread_id_t tid) if (old_size <= thread_id) { thrd_target_nodes.resize(thread_id + 1); - for (int i = old_size; i < thread_id + 1; i++) { + for (int i = old_size;i < thread_id + 1;i++) { thrd_target_nodes[i] = new node_set_t(16); } } @@ -142,8 +144,10 @@ bool WaitObj::incr_counter(thread_id_t tid) } thrd_action_counters[thread_id]++; - if (thrd_action_counters[thread_id] > 1000) + if (thrd_action_counters[thread_id] > COUNTER_THRESHOLD) { + thrd_action_counters[thread_id] = 0; return true; + } return false; } @@ -164,6 +168,8 @@ void WaitObj::clear_waiting_for() target_nodes->reset(); } + delete iter; + waiting_for.reset(); /* waited_by relation should be kept */ } @@ -181,11 +187,12 @@ void WaitObj::print_waiting_for(bool verbose) model_print("%d ", waiting_for_id); } model_print("\n"); + delete it; if (verbose) { /* Print out the distances from each thread to target nodes */ model_print("\t"); - for (uint i = 0; i < thrd_target_nodes.size(); i++) { + for (uint i = 0;i < thrd_target_nodes.size();i++) { dist_map_t * dist_map = getDistMap(i); node_set_t * node_set = getTargetNodes(i); node_set_iter * node_iter = node_set->iterator(); @@ -193,13 +200,15 @@ void WaitObj::print_waiting_for(bool verbose) if (!node_set->isEmpty()) { model_print("[thread %d](", int_to_id(i)); - while (node_iter->hasNext()){ + while (node_iter->hasNext()) { FuncNode * node = node_iter->next(); int dist = dist_map->get(node); model_print("node %d: %d, ", node->get_func_id(), dist); } model_print(") "); } + + delete node_iter; } model_print("\n"); } @@ -218,4 +227,6 @@ void WaitObj::print_waited_by() model_print("%d ", thread_id); } model_print("\n"); + + delete it; }