/** @brief The last fence release from the same thread */
const ModelAction *last_fence_release;
ModelAction * uninitaction;
-
+
/**
* @brief The clock vector for this operation
*
*/
ClockVector *cv;
ClockVector *rf_cv;
-
+
/** @brief The value written (for write or RMW; undefined for read) */
uint64_t value;
thrd_last_action(1),
thrd_last_fence_release(),
priv(new struct model_snapshot_members ()),
- mo_graph(new CycleGraph()),
+ mo_graph(new CycleGraph()),
fuzzer(new Fuzzer())
{
/* Initialize a model-checker thread, for special ModelActions */
if (!second_part_of_rmw && curr->get_type() != NOOP)
add_action_to_lists(curr);
+ if (curr->is_write())
+ add_write_to_lists(curr);
+
SnapVector<ModelAction *> * rf_set = NULL;
/* Build may_read_from set for newly-created actions */
if (newly_explored && curr->is_read())
}
i--;
if (i >= 0) {
- rf = (*processset)[i];
+ rf = (*processset)[i];
} else
- break;
+ break;
}
if (processset != NULL)
delete processset;
}
}
+void ModelExecution::add_write_to_lists(ModelAction *write) {
+ // Update seq_cst map
+ if (write->is_seqcst())
+ obj_last_sc_map.put(write->get_location(), write);
+}
+
/**
* @brief Get the last action performed by a particular Thread
* @param tid The thread ID of the Thread in question
ModelAction * ModelExecution::get_last_seq_cst_write(ModelAction *curr) const
{
void *location = curr->get_location();
- action_list_t *list = obj_map.get(location);
- /* Find: max({i in dom(S) | seq_cst(t_i) && isWrite(t_i) && samevar(t_i, t)}) */
- action_list_t::reverse_iterator rit;
- for (rit = list->rbegin();(*rit) != curr;rit++)
- ;
- rit++; /* Skip past curr */
- for ( ;rit != list->rend();rit++)
- if ((*rit)->is_write() && (*rit)->is_seqcst())
- return *rit;
- return NULL;
+ return obj_last_sc_map.get(location);
}
/**
bool synchronize(const ModelAction *first, ModelAction *second);
void add_action_to_lists(ModelAction *act);
+ void add_write_to_lists(ModelAction *act);
ModelAction * get_last_fence_release(thread_id_t tid) const;
ModelAction * get_last_seq_cst_write(ModelAction *curr) const;
ModelAction * get_last_seq_cst_fence(thread_id_t tid, const ModelAction *before_fence) const;
HashTable<const void *, ModelAction *, uintptr_t, 4> obj_last_sc_map;
-
+
HashTable<pthread_mutex_t *, cdsc::snapmutex *, uintptr_t, 4> mutex_map;
HashTable<pthread_cond_t *, cdsc::snapcondition_variable *, uintptr_t, 4> cond_map;
*/
uint64_t ModelChecker::switch_to_master(ModelAction *act)
{
- if (forklock) {
- static bool fork_message_printed = false;
-
- if (!fork_message_printed) {
- model_print("Fork handler trying to call into model checker...\n");
- fork_message_printed = true;
- }
- delete act;
- return 0;
- }
- DBG();
+ if (forklock) {
+ static bool fork_message_printed = false;
+
+ if (!fork_message_printed) {
+ model_print("Fork handler trying to call into model checker...\n");
+ fork_message_printed = true;
+ }
+ delete act;
+ return 0;
+ }
+ DBG();
Thread *old = thread_current();
scheduler->set_current_thread(NULL);
ASSERT(!old->get_pending());