return (*thrd_wait_obj)[thread_id];
}
+void ModelHistory::add_waiting_thread(thread_id_t self_id,
+ thread_id_t waiting_for_id, int dist)
+{
+ WaitObj * self_wait_obj = getWaitObj(self_id);
+ self_wait_obj->add_waiting_for(waiting_for_id, dist);
+
+ /* Update waited-by relation */
+ WaitObj * other_wait_obj = getWaitObj(waiting_for_id);
+ other_wait_obj->add_waited_by(self_id);
+}
+
+void ModelHistory::remove_waiting_thread(thread_id_t self_id, thread_id_t waiting_for_id)
+{
+ WaitObj * self_wait_obj = getWaitObj(self_id);
+ self_wait_obj->remove_waiting_for(waiting_for_id);
+
+ /* Update waited-by relation */
+ WaitObj * other_wait_obj = getWaitObj(waiting_for_id);
+ other_wait_obj->remove_waited_by(self_id);
+}
+
+
SnapVector<inst_act_map_t *> * ModelHistory::getThrdInstActMap(uint32_t func_id)
{
ASSERT(func_id != 0);
thread_id_t tid = int_to_id(i);
WaitObj * wait_obj = getWaitObj(tid);
wait_obj->print_waiting_for();
+ }
+
+ for (unsigned int i = 0; i < execution->get_num_threads();i++) {
+ thread_id_t tid = int_to_id(i);
+ WaitObj * wait_obj = getWaitObj(tid);
wait_obj->print_waited_by();
}
}
void remove_waiting_write(thread_id_t tid);
void check_waiting_write(ModelAction * write_act);
SnapVector<ConcretePredicate *> * getThrdWaitingWrite() { return thrd_waiting_write; }
- thrd_id_set_t * getWaitingFor(thread_id_t tid);
+
WaitObj * getWaitObj(thread_id_t tid);
+ void add_waiting_thread(thread_id_t self_id, thread_id_t waiting_for_id, int dist);
+ void remove_waiting_thread(thread_id_t self_id, thread_id_t waiting_for_id);
SnapVector<inst_act_map_t *> * getThrdInstActMap(uint32_t func_id);
{
void * location = pending_read->get_location();
thread_id_t self_id = pending_read->get_tid();
- HashSet<thread_id_t, int, 0> waiting_for_threads(64);
SnapVector<FuncNode *> * func_node_list = history->getWrFuncNodes(location);
for (uint i = 0; i < func_node_list->size(); i++) {
int distance = node->compute_distance(target_node);
if (distance != -1) {
- waiting_for_threads.add(tid);
+ history->add_waiting_thread(self_id, tid, distance);
model_print("thread: %d; distance from node %d to node %d: %d\n", tid, node->get_func_id(), target_node->get_func_id(), distance);
}
}
}
-
- /* Clear list first */
- WaitObj * wait_obj = history->getWaitObj(self_id);
- thrd_id_set_t * waiting_threads = wait_obj->getWaitingFor();
- waiting_threads->reset();
-
- HSIterator<thread_id_t, int, 0> * it = waiting_for_threads.iterator();
- while (it->hasNext()) {
- thread_id_t tid = it->next();
- waiting_threads->add(tid);
- }
}
bool NewFuzzer::shouldWait(const ModelAction * act)
dist_table(32)
{}
+void WaitObj::add_waiting_for(thread_id_t other, int dist)
+{
+ waiting_for.add(other);
+ dist_table.put(other, dist);
+}
+
+void WaitObj::add_waited_by(thread_id_t other)
+{
+ waited_by.add(other);
+}
+
+void WaitObj::remove_waiting_for(thread_id_t other)
+{
+ waiting_for.remove(other);
+ dist_table.remove(other);
+}
+
+void WaitObj::remove_waited_by(thread_id_t other)
+{
+ waited_by.remove(other);
+}
+
int WaitObj::lookup_dist(thread_id_t other_id)
{
if (dist_table.contains(other_id))
return -1;
}
+void WaitObj::reset()
+{
+ waiting_for.reset();
+ waited_by.reset();
+ dist_table.reset();
+}
+
void WaitObj::print_waiting_for()
{
if (waiting_for.getSize() == 0)
thread_id_t get_tid() { return tid; }
+ void add_waiting_for(thread_id_t other, int dist);
+ void add_waited_by(thread_id_t other);
+ void remove_waiting_for(thread_id_t other);
+ void remove_waited_by(thread_id_t other);
+
thrd_id_set_t * getWaitingFor() { return &waiting_for; }
thrd_id_set_t * getWaitingBy() { return &waited_by; }
int lookup_dist(thread_id_t other_tid);
+ void reset();
+
void print_waiting_for();
void print_waited_by();