Mercurial > hg > Applications > Grep
comparison parallel_processing/ppb_cond_counter/ppb_cond_counter.c @ 18:7efe4455deaa
fix
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 06 Jan 2014 16:26:54 +0900 |
parents | 4d8d124528f2 |
children |
comparison
equal
deleted
inserted
replaced
17:4d8d124528f2 | 18:7efe4455deaa |
---|---|
13 thread_func(void *arg) | 13 thread_func(void *arg) |
14 { | 14 { |
15 long id = (long)arg; | 15 long id = (long)arg; |
16 | 16 |
17 pthread_mutex_lock(&mutex); | 17 pthread_mutex_lock(&mutex); |
18 while (thread_num >= MAX_THREAD_NUM) pthread_cond_wait(&cond, &mutex); | 18 while (thread_num >= MAX_THREAD_NUM) |
19 pthread_cond_wait(&cond, &mutex); | |
19 thread_num++; | 20 thread_num++; |
20 pthread_mutex_unlock(&mutex); | 21 pthread_mutex_unlock(&mutex); |
21 | 22 |
22 printf("Thread %ld started.\n", id); | 23 printf("Thread %ld started.\n", id); |
23 sleep(1); | 24 sleep(1); |