fix bug
[c11tester.git] / fuzzer.cc
1 #include "fuzzer.h"
2 #include <stdlib.h>
3 #include "threads-model.h"
4 #include "model.h"
5
6 int Fuzzer::selectWrite(ModelAction *read, SnapVector<ModelAction *> * rf_set) {
7         int random_index = random() % rf_set->size();
8         return random_index;
9 }
10
11 Thread * Fuzzer::selectThread(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         sllnode<ModelAction*> * it = waiters->begin();
22         while(random_index--)
23                 it=it->getNext();
24         Thread *thread = model->get_thread(it->getVal());
25         waiters->erase(it);
26         return thread;
27 }