X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6924ac0d1c39cfc2ff29a21b3a32ba9378973b02..8c077434920dc49c791c9ed5c3ad7cbbc8faec15:/examples/sthread/pthread-producer-consumer.c diff --git a/examples/sthread/pthread-producer-consumer.c b/examples/sthread/pthread-producer-consumer.c index 52a0080256..fe3fe5d960 100644 --- a/examples/sthread/pthread-producer-consumer.c +++ b/examples/sthread/pthread-producer-consumer.c @@ -45,9 +45,10 @@ static void* consumer(void* id) for (int i = 0; i < AmountConsumed; i++) { sem_wait(&full); pthread_mutex_lock(&mutex); - int item = buffer[out]; - if (do_output) + if (do_output) { + int item = buffer[out]; fprintf(stderr, "Consumer %d: Remove Item %d from %d\n", *((int*)id), item, out); + } out = (out + 1) % BufferSize; pthread_mutex_unlock(&mutex); sem_post(&empty);