Add sleep score
[c11tester.git] / newfuzzer.h
index 7de4cd7696f5afdeea7404df697c140018edda9e..e94de3387f471a981cb0e5a02fad59171919bbb7 100644 (file)
@@ -6,21 +6,18 @@
 #include "mymemory.h"
 #include "stl-model.h"
 
-typedef HashTable<FuncInst *, ModelAction *, uintptr_t, 0> inst_act_map_t;
-
 class NewFuzzer : public Fuzzer {
 public:
        NewFuzzer();
        int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
-       Predicate * get_selected_child_branch(thread_id_t tid);
-       void conditional_sleep(Thread * thread);
        bool has_paused_threads();
-       void wake_up_paused_threads(int * threadlist, int * numthreads);
+       void notify_paused_thread(Thread * thread);
 
        Thread * selectThread(int * threadlist, int numthreads);
        Thread * selectNotify(action_list_t * waiters);
-       bool shouldSleep(const ModelAction *sleep);
-       bool shouldWake(const ModelAction *sleep);
+       bool shouldSleep(const ModelAction * sleep);
+       bool shouldWake(const ModelAction * sleep);
+       bool shouldWait(const ModelAction * wait);
 
        void register_engine(ModelHistory * history, ModelExecution * execution);
 
@@ -30,17 +27,27 @@ private:
        ModelExecution * execution;
 
        SnapVector<ModelAction *> thrd_last_read_act;
-       SnapVector<Predicate *> thrd_curr_pred;
+       SnapVector<FuncInst *> thrd_last_func_inst;
+
        SnapVector<Predicate *> thrd_selected_child_branch;
        SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
 
+       Predicate * get_selected_child_branch(thread_id_t tid);
        bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map);
        Predicate * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst);
+       int choose_index(SnapVector<Predicate *> * branches, uint32_t numerator);
 
-       /* Threads put to sleep by NewFuzzer because no writes in rf_set satisfies the selected predicate.
-        * Only used by selectWrite;
+       /* The set of Threads put to sleep by NewFuzzer because no writes in rf_set satisfies the selected predicate. Only used by selectWrite.
         */
-       SnapVector<Thread *> paused_thread_set;
+       SnapVector<Thread *> paused_thread_list;
+       HashTable<Thread *, int, uintptr_t, 0> paused_thread_table;
+       HashTable<Predicate *, bool, uintptr_t, 0> failed_predicates;
+
+       void conditional_sleep(Thread * thread);
+       void wake_up_paused_threads(int * threadlist, int * numthreads);
+
+       bool find_threads(ModelAction * pending_read);
+       void update_predicate_score(Predicate * predicate, int type);
 };
 
 #endif /* end of __NEWFUZZER_H__ */