Rev 534 | Rev 1062 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 534 | Rev 627 | ||
---|---|---|---|
Line 87... | Line 87... | ||
87 | 87 | ||
88 | 88 | ||
89 | for (i=1; i<=3; i++) { |
89 | for (i=1; i<=3; i++) { |
90 | thread_t *thrd; |
90 | thread_t *thrd; |
91 | 91 | ||
92 | items_produced = 0; |
92 | atomic_set(&items_produced, 0); |
93 | items_consumed = 0; |
93 | atomic_set(&items_consumed, 0); |
94 | 94 | ||
95 | consumers = i * CONSUMERS; |
95 | consumers = i * CONSUMERS; |
96 | producers = (4-i) * PRODUCERS; |
96 | producers = (4-i) * PRODUCERS; |
97 | 97 | ||
98 | printf("Creating %d consumers and %d producers...", consumers, producers); |
98 | printf("Creating %d consumers and %d producers...", consumers, producers); |
Line 117... | Line 117... | ||
117 | printf("ok\n"); |
117 | printf("ok\n"); |
118 | 118 | ||
119 | thread_sleep(1); |
119 | thread_sleep(1); |
120 | waitq_wakeup(&can_start, WAKEUP_ALL); |
120 | waitq_wakeup(&can_start, WAKEUP_ALL); |
121 | 121 | ||
122 | while (items_consumed != consumers || items_produced != producers) { |
122 | while (items_consumed.count != consumers || items_produced.count != producers) { |
123 | printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed, producers - items_produced); |
123 | printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count); |
124 | thread_sleep(1); |
124 | thread_sleep(1); |
125 | } |
125 | } |
126 | } |
126 | } |
127 | printf("Test passed.\n"); |
127 | printf("Test passed.\n"); |
128 | } |
128 | } |