Fork handler mitigations
[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(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 }