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)
55 return location == act->location;
58 bool ModelAction::same_thread(ModelAction *act)
60 return tid == act->tid;
63 bool ModelAction::is_dependent(ModelAction *act)
65 if (!is_read() && !is_write())
67 if (!act->is_read() && !act->is_write())
69 if (same_var(act) && !same_thread(act) &&
70 (is_write() || act->is_write()))
75 void ModelAction::print(void)
80 type_str = "thread create";
83 type_str = "thread yield";
86 type_str = "thread join";
89 type_str = "atomic read";
92 type_str = "atomic write";
95 type_str = "unknown type";
98 printf("(%4d) Thread: %d\tAction: %s\tMO: %d\tLoc: %14p\tValue: %d\n",
99 seq_number, id_to_int(tid), type_str, order, location, value);