Add some methods for WaitObj
[c11tester.git] / newfuzzer.h
index c956935e8cef70b354302e83449722148a34bc31..0e5d483bea9c96d8e0edff2956ecb2c2ed7f93f9 100644 (file)
@@ -6,20 +6,19 @@
 #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 * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst);
        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);
+       bool has_paused_threads();
+       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);
 
@@ -32,6 +31,19 @@ private:
        SnapVector<Predicate *> thrd_curr_pred;
        SnapVector<Predicate *> thrd_selected_child_branch;
        SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
+
+       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);
+
+       /* 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;
+       HashTable<Thread *, int, uintptr_t, 0> paused_thread_table;
+
+       void conditional_sleep(Thread * thread);
+       void wake_up_paused_threads(int * threadlist, int * numthreads);
+
+       void find_threads(ModelAction * pending_read);
 };
 
 #endif /* end of __NEWFUZZER_H__ */