6 ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value)
8 Thread *t = thread_current();
9 ModelAction *act = this;
14 act->tid = t->get_id();
16 act->seq_number = model->get_next_seq_num();
19 bool ModelAction::is_read()
21 return type == ATOMIC_READ;
24 bool ModelAction::is_write()
26 return type == ATOMIC_WRITE;
29 bool ModelAction::is_acquire()
32 case memory_order_acquire:
33 case memory_order_acq_rel:
34 case memory_order_seq_cst:
41 bool ModelAction::is_release()
44 case memory_order_release:
45 case memory_order_acq_rel:
46 case memory_order_seq_cst:
53 bool ModelAction::same_var(ModelAction *act)
56 // TODO: fix stack allocation... return location == act->location;
59 bool ModelAction::same_thread(ModelAction *act)
61 return tid == act->tid;
64 bool ModelAction::is_dependent(ModelAction *act)
66 if (!is_read() && !is_write())
68 if (!act->is_read() && !act->is_write())
70 if (same_var(act) && !same_thread(act) &&
71 (is_write() || act->is_write()))
76 void ModelAction::print(void)
81 type_str = "thread create";
84 type_str = "thread yield";
87 type_str = "thread join";
90 type_str = "atomic read";
93 type_str = "atomic write";
96 type_str = "unknown type";
99 printf("(%4d) Thread: %d\tAction: %s\tMO: %d\tLoc: %14p\tValue: %d\n",
100 seq_number, id_to_int(tid), type_str, order, location, value);