struct model_snapshot_members;
struct bug_message;
- typedef SnapList<ModelAction *> action_list_t;
++typedef SnapList<ModelAction *> simple_action_list_t;
+ typedef actionlist action_list_t;
typedef SnapList<uint32_t> func_id_list_t;
typedef SnapList<FuncInst *> func_inst_list_t;
return tmp;
}
++static simple_action_list_t * get_safe_ptr_action(HashTable<const void *, simple_action_list_t *, uintptr_t, 2> * hash, void * ptr)
++{
++ simple_action_list_t *tmp = hash->get(ptr);
++ if (tmp == NULL) {
++ tmp = new simple_action_list_t();
++ hash->put(ptr, tmp);
++ }
++ return tmp;
++}
++
/** @return a thread ID for a new Thread */
thread_id_t ModelExecution::get_next_id()
{
/* unlock the lock - after checking who was waiting on it */
state->locked = NULL;
- /* disable this thread */
- get_safe_ptr_action(&condvar_waiters_map, curr->get_location())->addAction(curr);
+ /* remove old wait action and disable this thread */
- action_list_t * waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
++ simple_action_list_t * waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
+ for (sllnode<ModelAction *> * it = waiters->begin(); it != NULL; it = it->getNext()) {
+ ModelAction * wait = it->getVal();
+ if (wait->get_tid() == curr->get_tid()) {
+ waiters->erase(it);
+ break;
+ }
+ }
+
+ waiters->push_back(curr);
scheduler->sleep(get_thread(curr));
}
break;
}
case ATOMIC_NOTIFY_ALL: {
-- action_list_t *waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
++ simple_action_list_t *waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
//activate all the waiting threads
for (sllnode<ModelAction *> * rit = waiters->begin();rit != NULL;rit=rit->getNext()) {
scheduler->wake(get_thread(rit->getVal()));
break;
}
case ATOMIC_NOTIFY_ONE: {
-- action_list_t *waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
++ simple_action_list_t *waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
if (waiters->size() != 0) {
Thread * thread = fuzzer->selectNotify(waiters);
scheduler->wake(thread);
/** Per-object list of actions. Maps an object (i.e., memory location)
* to a trace of all actions performed on the object. */
-- HashTable<const void *, action_list_t *, uintptr_t, 2> condvar_waiters_map;
++ HashTable<const void *, simple_action_list_t *, uintptr_t, 2> condvar_waiters_map;
/** Per-object list of actions that each thread performed. */
HashTable<const void *, SnapVector<action_list_t> *, uintptr_t, 2> obj_thrd_map;
return model->get_thread(curr_tid);
}
--Thread * Fuzzer::selectNotify(action_list_t * waiters) {
++Thread * Fuzzer::selectNotify(simple_action_list_t * waiters) {
int numwaiters = waiters->size();
int random_index = random() % numwaiters;
sllnode<ModelAction*> * it = waiters->begin();
bool Fuzzer::shouldWait(const ModelAction * act)
{
-- return random() & 1;
++ return true;
}
virtual bool has_paused_threads() { return false; }
virtual Thread * selectThread(int * threadlist, int numthreads);
-- Thread * selectNotify(action_list_t * waiters);
++ Thread * selectNotify(simple_action_list_t * waiters);
bool shouldSleep(const ModelAction *sleep);
bool shouldWake(const ModelAction *sleep);
virtual bool shouldWait(const ModelAction *wait);
void notify_paused_thread(Thread * thread);
Thread * selectThread(int * threadlist, int numthreads);
-- Thread * selectNotify(action_list_t * waiters);
++ Thread * selectNotify(simple_action_list_t * waiters);
bool shouldSleep(const ModelAction * sleep);
bool shouldWake(const ModelAction * sleep);
bool shouldWait(const ModelAction * wait);