Make our pthread id starts from 2. Reserve id 1 for main thread
authorweiyu <weiyuluo1232@gmail.com>
Wed, 25 Mar 2020 19:48:50 +0000 (12:48 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Wed, 25 Mar 2020 19:48:50 +0000 (12:48 -0700)
execution.cc
include/mutex.h
newfuzzer.cc

index de54394c49a034aedec1465082ce316f19a21bc5..97e58511e0307c3d4d2fe06177178e53718f5675 100644 (file)
@@ -53,7 +53,7 @@ ModelExecution::ModelExecution(ModelChecker *m, Scheduler *scheduler) :
        scheduler(scheduler),
        thread_map(2),  /* We'll always need at least 2 threads */
        pthread_map(0),
        scheduler(scheduler),
        thread_map(2),  /* We'll always need at least 2 threads */
        pthread_map(0),
-       pthread_counter(1),
+       pthread_counter(2),
        action_trace(),
        obj_map(),
        condvar_waiters_map(),
        action_trace(),
        obj_map(),
        condvar_waiters_map(),
@@ -1605,18 +1605,21 @@ Thread * ModelExecution::get_thread(const ModelAction *act) const
  * @return A Thread reference
  */
 Thread * ModelExecution::get_pthread(pthread_t pid) {
  * @return A Thread reference
  */
 Thread * ModelExecution::get_pthread(pthread_t pid) {
+       // pid 1 is reserved for the main thread, pthread ids should start from 2
+       if (pid == 1)
+               return get_thread(pid);
+
        union {
                pthread_t p;
                uint32_t v;
        } x;
        x.p = pid;
        uint32_t thread_id = x.v;
        union {
                pthread_t p;
                uint32_t v;
        } x;
        x.p = pid;
        uint32_t thread_id = x.v;
-       return get_thread(thread_id);   // Temporary fix for firefox
 
 
-/*
-       if (thread_id < pthread_counter + 1) return pthread_map[thread_id];
-       else return NULL;
-*/
+       if (thread_id < pthread_counter + 1)
+               return pthread_map[thread_id];
+       else
+               return NULL;
 }
 
 /**
 }
 
 /**
index 64473b2ae783d1e83313ca5d179128e6c0bb8502..f5894952282be7024867a8880793383f82b8e5f7 100644 (file)
@@ -14,7 +14,6 @@ struct mutex_state {
        void *locked;   /* Thread holding the lock */
        thread_id_t alloc_tid;
        modelclock_t alloc_clock;
        void *locked;   /* Thread holding the lock */
        thread_id_t alloc_tid;
        modelclock_t alloc_clock;
-       int init;       // WL
 };
 
 class mutex {
 };
 
 class mutex {
index fca9da8d48896504b6aafeea2dda40060a10e1a8..01eed86ba1489b983fadd0bc34cc9cfb94d5b875 100644 (file)
@@ -447,5 +447,5 @@ bool NewFuzzer::find_threads(ModelAction * pending_read)
 
 bool NewFuzzer::shouldWait(const ModelAction * act)
 {
 
 bool NewFuzzer::shouldWait(const ModelAction * act)
 {
-       return random() & 1;
+       return true;
 }
 }