- int random_index = random() % rf_set->size();
- bool updated = false;
-
- const ModelAction *rf = (*rf_set)[random_index];
- ASSERT(rf);
-
- mo_graph->startChanges();
-
- updated = r_modification_order(curr, rf);
- read_from(curr, rf);
- mo_graph->commitChanges();
- get_thread(curr)->set_return_value(curr->get_return_value());
- return updated;
+ SnapVector<const ModelAction *> * priorset = new SnapVector<const ModelAction *>();
+ while(true) {
+
+ int index = fuzzer->selectWrite(curr, rf_set);
+ const ModelAction *rf = (*rf_set)[index];
+
+
+ ASSERT(rf);
+ bool canprune = false;
+ if (r_modification_order(curr, rf, priorset, &canprune)) {
+ for(unsigned int i=0;i<priorset->size();i++) {
+ mo_graph->addEdge((*priorset)[i], rf);
+ }
+ read_from(curr, rf);
+ get_thread(curr)->set_return_value(curr->get_return_value());
+ delete priorset;
+ if (canprune && curr->get_type() == ATOMIC_READ) {
+ int tid = id_to_int(curr->get_tid());
+ (*obj_thrd_map.get(curr->get_location()))[tid].pop_back();
+ }
+ return;
+ }
+ priorset->clear();
+ (*rf_set)[index] = rf_set->back();
+ rf_set->pop_back();
+ }