Test prettyfy

This commit is contained in:
pithikos 2015-01-13 13:45:03 +00:00
parent 6363733f8a
commit 17aa5fe9ed

View File

@ -8,7 +8,7 @@ pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int sum=0; int sum=0;
void add_one() { void increment() {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
sum ++; sum ++;
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
@ -25,15 +25,15 @@ int main(int argc, char *argv[]){
int jobs = strtol(argv[1], &p, 10); int jobs = strtol(argv[1], &p, 10);
int threads = strtol(argv[2], &p, 10); int threads = strtol(argv[2], &p, 10);
thpool_t* threadpool; thpool_t* thpool;
threadpool = thpool_init(threads); thpool = thpool_init(threads);
int n; int n;
for (n=0; n<jobs; n++){ for (n=0; n<jobs; n++){
thpool_add_work(threadpool, (void*)add_one, NULL); thpool_add_work(thpool, (void*)increment, NULL);
} }
thpool_wait(threadpool); thpool_wait(thpool);
printf("%d\n", sum); printf("%d\n", sum);