A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Properly register the waiter in wait_any_for(), so that it gets handled on suspend...
[simgrid.git]
/
examples
/
sthread
/
pthread-producer-consumer.c
diff --git
a/examples/sthread/pthread-producer-consumer.c
b/examples/sthread/pthread-producer-consumer.c
index 52a00802569d253acedbd4c7ab78909e1b35ff88..fe3fe5d960b0b12bfe790fcda3fb06499909b155 100644
(file)
--- 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);
for (int i = 0; i < AmountConsumed; i++) {
sem_wait(&full);
pthread_mutex_lock(&mutex);
- i
nt item = buffer[out];
- if (do_output)
+ i
f (do_output) {
+ int item = buffer[out];
fprintf(stderr, "Consumer %d: Remove Item %d from %d\n", *((int*)id), item, 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);
out = (out + 1) % BufferSize;
pthread_mutex_unlock(&mutex);
sem_post(&empty);