+ {
+ sema_down (&threads[i].done);
+ threads[i].iterations = 1;
+ }
+
+ /* Print output buffer. */
+ product = 0;
+ for (; output < op; output++)
+ {
+ struct sleep_thread_data *t;
+ int new_prod;
+
+ ASSERT (*output >= 0 && *output < thread_cnt);
+ t = threads + *output;
+
+ new_prod = t->iterations++ * t->duration;
+
+ printf ("thread %d: duration=%d, iteration=%d, product=%d\n",
+ t->id, t->duration, t->iterations, new_prod);
+
+ if (new_prod >= product)
+ product = new_prod;
+ else
+ printf ("thread %d: Out of order sleep completion (%d > %d)!\n",
+ t->id, product, new_prod);
+ }