return size;
}
+ bool isEmpty() {
+ return size == 0;
+ }
/**
* @brief Check whether the table contains a value for the given key
thrd_func_act_lists = execution->get_thrd_func_act_lists();
uint32_t thread_id = id_to_int(tid);
- uint32_t func_id = (*thrd_func_list)[thread_id].back();
-
/* Return if thread tid has not entered any function that contains atomics */
if ( thrd_func_list->size() <= thread_id )
return;
check_waiting_write(act);
}
+ uint32_t func_id = (*thrd_func_list)[thread_id].back();
+
/* The following does not care about actions that are not inside
* any function that contains atomics or actions without a position */
if (func_id == 0 || act->get_position() == NULL)
return;
SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[thread_id];
+
/* The list of actions that thread tid has taken in its current function */
action_list_t * curr_act_list = func_act_lists->back();
- ASSERT(curr_act_list != NULL);
if (skip_action(act, curr_act_list))
return;
- FuncNode * func_node = func_nodes[func_id];
-
/* Add to curr_inst_list */
curr_act_list->push_back(act);
+
+ FuncNode * func_node = func_nodes[func_id];
func_node->add_inst(act);
if (act->is_read()) {
bool ModelHistory::skip_action(ModelAction * act, SnapList<ModelAction *> * curr_act_list)
{
+ ASSERT(curr_act_list != NULL);
+
bool second_part_of_rmw = act->is_rmwc() || act->is_rmw();
modelclock_t curr_seq_number = act->get_seq_number();
}
}
-void monitor_waiting_thread_counter(thread_id_t tid)
+void ModelHistory::monitor_waiting_thread_counter(thread_id_t tid)
{
WaitObj * wait_obj = getWaitObj(tid);
thrd_id_set_t * waited_by = wait_obj->getWaitedBy();
bool expire = other_wait_obj->incr_counter(tid);
if (expire) {
- // TODO: complete
- expire_threads.push_back(tid);
+ wait_obj->remove_waited_by(waited_by_id);
+ other_wait_obj->remove_waiting_for(tid);
+
+ thrd_id_set_t * other_waiting_for = other_wait_obj->getWaitingFor();
+ if ( other_waiting_for->isEmpty() ) {
+ // model_print("\tthread %d waits for nobody, wake up\n", self_id);
+ ModelExecution * execution = model->get_execution();
+ Thread * thread = execution->get_thread(waited_by_id);
+ execution->getFuzzer()->notify_paused_thread(thread);
+ }
}
}
}
/* The thread has no nodes to reach */
if (target_nodes->isEmpty()) {
+ int index = id_to_int(other);
+ thrd_action_counters[index] = 0;
waiting_for.remove(other);
+
return true;
}
/* Stop waiting for the thread */
void WaitObj::remove_waiting_for(thread_id_t other)
{
- // TODO: clear dist_map or not?
waiting_for.remove(other);
+ // TODO: clear dist_map or not?
+ /* dist_map_t * dist_map = getDistMap(other);
+ dist_map->reset(); */
+
node_set_t * target_nodes = getTargetNodes(other);
target_nodes->reset();
+
+ int index = id_to_int(other);
+ thrd_action_counters[index] = 0;
}
void WaitObj::remove_waited_by(thread_id_t other)
return thrd_target_nodes[thread_id];
}
-/*
-SnapVector<thread_id_t> WaitObj::incr_waiting_for_counter()
-{
- SnapVector<thread_id_t> expire_thrds;
-
- thrd_id_set_iter * iter = waiting_for.iterator();
- while (iter->hasNext()) {
- thread_id_t waiting_for_id = iter->next();
- bool expire = incr_counter(waiting_for_id);
-
- if (expire) {
- expire_thrds.push_back(waiting_for_id);
- }
- }
-
- return expire_thrds;
-}*/
-
/**
* Increment action counter for thread tid
* @return true if the counter for tid expires
}
thrd_action_counters[thread_id]++;
-
if (thrd_action_counters[thread_id] > 1000)
return true;
while (iter->hasNext()) {
thread_id_t tid = iter->next();
int index = id_to_int(tid);
- thrd_target_nodes[index]->reset();
+ thrd_action_counters[index] = 0;
+
/* thrd_dist_maps are not reset because distances
- * will be overwritten when node targets are added */
+ * will be overwritten when node targets are added
+ * thrd_dist_maps[index]->reset(); */
+
+ node_set_t * target_nodes = getTargetNodes(tid);
+ target_nodes->reset();
}
waiting_for.reset();
void add_waiting_for(thread_id_t other, FuncNode * node, int dist);
void add_waited_by(thread_id_t other);
bool remove_waiting_for_node(thread_id_t other, FuncNode * node);
+ void remove_waiting_for(thread_id_t other);
void remove_waited_by(thread_id_t other);
thrd_id_set_t * getWaitingFor() { return &waiting_for; }
int lookup_dist(thread_id_t tid, FuncNode * target);
bool incr_counter(thread_id_t tid);
- // SnapVector<thread_id_t> incr_waiting_for_counter();
void clear_waiting_for();