hence by iteself does not indicate no value. */
#define VALUE_NONE 1234567890
+#define VALUE_TRYSUCCESS 1
+#define VALUE_TRYFAILED 0
/** @brief Represents an action type, identifying one of several types of
* ModelAction */
Node * get_node() const { return node; }
void set_node(Node *n) { node = n; }
+ bool is_success_lock() const;
+ bool is_failed_trylock() const;
bool is_read() const;
bool is_write() const;
bool is_rmwr() const;
lazy_sync_with_release(new HashTable<void *, std::list<ModelAction *>, uintptr_t, 4>()),
thrd_last_action(new std::vector<ModelAction *>(1)),
node_stack(new NodeStack()),
+ is_enabled(NULL),
mo_graph(new CycleGraph()),
failed_promise(false),
too_many_reads(false),
for (int i = 0; i < get_num_threads(); i++)
delete thread_map->get(i);
delete thread_map;
+ if (is_enabled)
+ free(is_enabled);
delete obj_thrd_map;
delete obj_map;
/** @returns a thread ID for a new Thread */
thread_id_t ModelChecker::get_next_id()
{
- return priv->next_thread_id++;
+ thread_id_t newid=priv->next_thread_id++;
+ bool * tmp=(bool *) malloc((newid+1)*sizeof(bool));
+ memcpy(tmp, is_enabled, newid*sizeof(bool));
+ tmp[newid]=true;
+ free(is_enabled);
+ is_enabled=tmp;
+ return newid;
}
/** @returns the number of user threads created during this execution */
{
action_type type = act->get_type();
- switch (type) {
- case ATOMIC_READ:
- case ATOMIC_WRITE:
- case ATOMIC_RMW:
- break;
- default:
- return NULL;
- }
- /* linear search: from most recent to oldest */
- action_list_t *list = obj_map->get_safe_ptr(act->get_location());
- action_list_t::reverse_iterator rit;
- for (rit = list->rbegin(); rit != list->rend(); rit++) {
- ModelAction *prev = *rit;
- if (act->is_synchronizing(prev))
- return prev;
+ if (type==ATOMIC_READ||type==ATOMIC_WRITE||type==ATOMIC_RMW) {
+ /* linear search: from most recent to oldest */
+ action_list_t *list = obj_map->get_safe_ptr(act->get_location());
+ action_list_t::reverse_iterator rit;
+ for (rit = list->rbegin(); rit != list->rend(); rit++) {
+ ModelAction *prev = *rit;
+ if (act->is_synchronizing(prev))
+ return prev;
+ }
+ } else if (type==ATOMIC_LOCK||type==ATOMIC_TRYLOCK) {
+ /* linear search: from most recent to oldest */
+ action_list_t *list = obj_map->get_safe_ptr(act->get_location());
+ action_list_t::reverse_iterator rit;
+ for (rit = list->rbegin(); rit != list->rend(); rit++) {
+ ModelAction *prev = *rit;
+ if (prev->is_success_lock())
+ return prev;
+ }
+ } else if (type==ATOMIC_UNLOCK) {
+ /* linear search: from most recent to oldest */
+ action_list_t *list = obj_map->get_safe_ptr(act->get_location());
+ action_list_t::reverse_iterator rit;
+ for (rit = list->rbegin(); rit != list->rend(); rit++) {
+ ModelAction *prev = *rit;
+ if (prev->is_failed_trylock())
+ return prev;
+ }
}
return NULL;
}