From 803d805c74466a9d736455930b17de2d9f5cb02d Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 27 Feb 2020 16:14:44 -0600 Subject: Complete the comment on thread_main(), explaining why the barrier is used. --- test/thread_id.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/thread_id.c b/test/thread_id.c index e3cf42e..818ab4a 100644 --- a/test/thread_id.c +++ b/test/thread_id.c @@ -226,7 +226,15 @@ atomic_printf(const char *fmt, ...) /* Each thread runs this routine. The routine fetches the current * thread's ID, makes sure that it is in the expected range, makes * sure that in this round of testing, no two threads shared the - * same ID, + * same ID, and checks that each thread's ID is constant over its lifetime. + * + * main() checks that every ID in [1, NTHREADS] is used in each round + * of testing. All NTHREADS threads synchronize on a barrier after each + * has fetched its ID. The barrier guarantees that all threads' lifetimes + * overlap at least momentarily, so the IDs will be unique, and there + * will be NTHREADS of them. Further, since thread IDs are assigned + * starting with 1, and the number of threads with IDs alive never exceeds + * NTHREADS, the least ID has to be 1 and the greatest, NTHREADS. */ static void * thread_main(void H5_ATTR_UNUSED *arg) -- cgit v0.12