update TODO's
[model-checker.git] / model.cc
index 1b379000d75f4832795190acc8e583f933ee7675..c86a6f676718d3fab6122282483786dd85589cb0 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -235,6 +235,11 @@ void ModelChecker::set_backtracking(ModelAction *act)
        }
 }
 
+/**
+ * Returns last backtracking point. The model checker will explore a different
+ * path for this point in the next execution.
+ * @return The ModelAction at which the next execution should diverge.
+ */
 ModelAction * ModelChecker::get_next_backtrack()
 {
        ModelAction *next = next_backtrack;
@@ -299,8 +304,6 @@ void ModelChecker::check_current_action(void)
        set_backtracking(curr);
 
        /* Assign reads_from values */
-       /* TODO: perform release/acquire synchronization here; include
-        * reads_from as ModelAction member? */
        Thread *th = get_thread(curr->get_tid());
        uint64_t value = VALUE_NONE;
        if (curr->is_read()) {
@@ -319,6 +322,7 @@ void ModelChecker::check_current_action(void)
        add_action_to_lists(curr);
 }
 
+/** @returns whether the current trace is feasible. */
 bool ModelChecker::isfeasible() {
        return !cyclegraph->checkForCycles();
 }
@@ -326,12 +330,16 @@ bool ModelChecker::isfeasible() {
 /** Process a RMW by converting previous read into a RMW. */
 void ModelChecker::process_rmw(ModelAction * act) {
        int tid = id_to_int(act->get_tid());
-       std::vector<action_list_t> *vec = &(*obj_thrd_map)[act->get_location()];
-       ASSERT(tid < (int) vec->size());
-       ModelAction *lastread=(*vec)[tid].back();
+       ModelAction *lastread=get_last_action(tid);
        lastread->upgrade_rmw(act);
+       cyclegraph->addRMWEdge(lastread->get_reads_from(),lastread);
 }
 
+/**
+ * Updates the cyclegraph with the constraints imposed from the current read.
+ * @param curr The current action. Must be a read.
+ * @param rf The action that curr reads from. Must be a write.
+ */
 void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *rf) {
        std::vector<action_list_t> *thrd_lists = &(*obj_thrd_map)[curr->get_location()];
        unsigned int i;
@@ -360,6 +368,10 @@ void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *r
        }
 }
 
+/**
+ * Updates the cyclegraph with the constraints imposed from the current write.
+ * @param curr The current action. Must be a write.
+ */
 void ModelChecker::w_modification_order(ModelAction * curr) {
        std::vector<action_list_t> *thrd_lists = &(*obj_thrd_map)[curr->get_location()];
        unsigned int i;
@@ -450,6 +462,11 @@ ModelAction * ModelChecker::get_parent_action(thread_id_t tid)
        return parent;
 }
 
+/**
+ * Returns the clock vector for a given thread.
+ * @param tid The thread whose clock vector we want
+ * @return Desired clock vector
+ */
 ClockVector * ModelChecker::get_cv(thread_id_t tid) {
        return get_parent_action(tid)->get_cv();
 }