#include "action.h"
#include "clockvector.h"
#include "common.h"
-#include "threads.h"
+#include "threads-model.h"
+#include "nodestack.h"
#define ACTION_INITIAL_CLOCK 0
location(loc),
value(value),
reads_from(NULL),
+ node(NULL),
seq_number(ACTION_INITIAL_CLOCK),
- cv(NULL)
+ cv(NULL),
+ sleep_flag(false)
{
+ /* References to NULL atomic variables can end up here */
+ ASSERT(loc || type == MODEL_FIXUP_RELSEQ);
+
Thread *t = thread ? thread : thread_current();
this->tid = t->get_id();
}
return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT;
}
+bool ModelAction::could_be_write() const
+{
+ return is_write() || is_rmwr();
+}
+
bool ModelAction::is_rmwr() const
{
return type == ATOMIC_RMWR;
// Explore interleavings of seqcst writes to guarantee total order
// of seq_cst operations that don't commute
- if ((is_write() || act->is_write()) && is_seqcst() && act->is_seqcst())
+ if ((could_be_write() || act->could_be_write()) && is_seqcst() && act->is_seqcst())
return true;
// Explore synchronizing read/write pairs
- if (is_read() && is_acquire() && act->is_write() && act->is_release())
+ if (is_read() && is_acquire() && act->could_be_write() && act->is_release())
return true;
// Otherwise handle by reads_from relation
break;
}
- printf("(%3d) Thread: %-2d Action: %-13s MO: %7s Loc: %14p Value: %-12" PRIu64,
+ printf("(%4d) Thread: %-2d Action: %-13s MO: %7s Loc: %14p Value: %-#18" PRIx64,
seq_number, id_to_int(tid), type_str, mo_str, location, valuetoprint);
if (is_read()) {
if (reads_from)
- printf(" Rf: %d", reads_from->get_seq_number());
+ printf(" Rf: %-3d", reads_from->get_seq_number());
else
- printf(" Rf: ?");
+ printf(" Rf: ? ");
}
if (cv) {
- printf("\t");
+ if (is_read())
+ printf(" ");
+ else
+ printf(" ");
cv->print();
} else
printf("\n");
}
+
+/** @brief Print nicely-formatted info about this ModelAction */
+unsigned int ModelAction::hash() const
+{
+ unsigned int hash=(unsigned int) this->type;
+ hash^=((unsigned int)this->order)<<3;
+ hash^=seq_number<<5;
+ hash^=tid<<6;
+
+ if (is_read()) {
+ if (reads_from)
+ hash^=reads_from->get_seq_number();
+ }
+ return hash;
+}