csci4061/lab11-code/odds_evens.h
Michael Zhang 041f660ccd
f
2018-01-29 17:28:37 -06:00

25 lines
634 B
C

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define NUM_THREADS 2 // number of odd/evens threads
#define TOT_THREADS (2*NUM_THREADS) // total threads
#ifndef THREAD_ITERS
#define THREAD_ITERS 5 // total iterations each thread will add on
#endif
#ifndef VPRINTF
#define VPRINTF printf
#endif
void ignore(char *s, int i, int j, int k){} // ignore requests to print
#ifndef SLEEPFUN
#define SLEEPFUN usleep(1)
#endif
void update(int *x){
*x = *x+1;
SLEEPFUN; // simulate some "work" done while locked
}