fatal error: 'common.h' file not found under mac osx 10.10.5

The "common.h" header for this problem is linked as a tgz bundle in the table of contents for the course next to chapter 1: http://pages.cs.wisc.edu/~remzi/OSTEP/

Drop it next to your source file and try compiling again.


Here is what you are looking for. All the other answers don't understand that you were working from an OS book. Please refer to the link provided on the site.

http://pages.cs.wisc.edu/~remzi/OSTEP/Code/code.intro.tgz

#ifndef __common_h__
#define __common_h__

#include <sys/time.h>
#include <assert.h>
#include <pthread.h>

double GetTime() {
    struct timeval t;
    int rc = gettimeofday(&t, NULL);
    assert(rc == 0);
    return (double)t.tv_sec + (double)t.tv_usec/1e6;
}

void Spin(int howlong) {
    double t = GetTime();
    while ((GetTime() - t) < (double)howlong)
    ; // do nothing in loop
}

void Pthread_create(pthread_t *t, const pthread_attr_t *attr,  
    void *(*start_routine)(void *), void *arg) {
    int rc = pthread_create(t, attr, start_routine, arg);
    assert(rc == 0);
}

void Pthread_join(pthread_t thread, void **value_ptr) {
    int rc = pthread_join(thread, value_ptr);
    assert(rc == 0);
}

void Pthread_mutex_lock(pthread_mutex_t *mutex) {
    int rc = pthread_mutex_lock(mutex);
    assert(rc == 0);
}

void Pthread_mutex_unlock(pthread_mutex_t *mutex) {
    int rc = pthread_mutex_unlock(mutex);
    assert(rc == 0);
}

void Pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) {
    int rc = pthread_mutex_init(mutex, attr);
    assert(rc == 0);
}


#endif // __common_h__

Tags:

C++

C

Macos