5 #include "clockvector.h"
7 ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value)
9 Thread *t = thread_current();
10 ModelAction *act = this;
15 act->tid = t->get_id();
17 act->seq_number = model->get_next_seq_num();
22 ModelAction::~ModelAction()
28 bool ModelAction::is_read()
30 return type == ATOMIC_READ;
33 bool ModelAction::is_write()
35 return type == ATOMIC_WRITE;
38 bool ModelAction::is_acquire()
41 case memory_order_acquire:
42 case memory_order_acq_rel:
43 case memory_order_seq_cst:
50 bool ModelAction::is_release()
53 case memory_order_release:
54 case memory_order_acq_rel:
55 case memory_order_seq_cst:
62 bool ModelAction::same_var(ModelAction *act)
64 return location == act->location;
67 bool ModelAction::same_thread(ModelAction *act)
69 return tid == act->tid;
72 bool ModelAction::is_dependent(ModelAction *act)
74 if (!is_read() && !is_write())
76 if (!act->is_read() && !act->is_write())
78 if (same_var(act) && !same_thread(act) &&
79 (is_write() || act->is_write()))
84 void ModelAction::print(void)
89 type_str = "thread create";
92 type_str = "thread yield";
95 type_str = "thread join";
98 type_str = "atomic read";
101 type_str = "atomic write";
104 type_str = "unknown type";
107 printf("(%4d) Thread: %d\tAction: %s\tMO: %d\tLoc: %14p\tValue: %d\n",
108 seq_number, id_to_int(tid), type_str, order, location, value);