Example #1
0
int pthread_mutex_lock(pthread_mutex_t *mutex) {
    //    init();
    //This is a non deterministic point . Capture non-determinism here
    findnextthreadtoschedule(NULL);

    // Call scheduler and wait for your turn
    sched();

    //I am not worthy of this lock
    while(!mutex_lock_validity(mutex)) {
        findnextthreadtoschedule(pthread_self());
        sched();
    }

    logChoice(all_thread.indexnum(pthread_self()),getActiveThreadNum());
    incrementLevel();

    PRINT("ACQUIRING LOCK %lx \n",mutex);
    lock_map.put(mutex,(pthread_self()));
    return original_pthread_mutex_lock(mutex);
    // TODO
}