62097b216f4997ea1574dd513b74099b0f569b8e
[c11tester.git] / fuzzer.cc
1 #include "fuzzer.h"
2 #include <stdlib.h>
3 #include "threads-model.h"
4 #include "model.h"
5
6 ModelAction * Fuzzer::selectWrite(ModelAction *read, ModelVector<ModelAction *> * rf_set) {
7   int random_index = random() % rf_set->size();
8   return (*rf_set)[random_index];
9 }
10
11 Thread * Fuzzer::selectThread(Node *n, int * threadlist, int numthreads) {
12   int random_index = random() % numthreads;
13   int thread = threadlist[random_index];
14   thread_id_t curr_tid = int_to_id(thread);
15   return model->get_thread(curr_tid);
16 }
17
18 Thread * Fuzzer::selectNotify(action_list_t * waiters) {
19   int numwaiters = waiters->size();
20   int random_index = random() % numwaiters;
21   action_list_t::iterator it = waiters->begin();
22   advance(it, random_index);
23   Thread *thread = model->get_thread(*it);
24   waiters->erase(it);
25   return thread;
26 }