MEDIUM: threads: replace ha_set_tid() with ha_set_thread()
ha_set_tid() was randomly used either to explicitly set thread 0 or to
set any possibly incomplete thread during boot. Let's replace it with
a pointer to a valid thread or NULL for any thread. This allows us to
check that the designated threads are always valid, and to ignore the
thread 0's mapping when setting it to NULL, and always use group 0 with
it during boot.
The initialization code is also cleaner, as we don't pass ugly casts
of a thread ID to a pointer anymore.
diff --git a/src/thread.c b/src/thread.c
index 2f904de..ce6a476 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -217,7 +217,7 @@
/* Create nbthread-1 thread. The first thread is the current process */
ha_pthread[0] = pthread_self();
for (i = 1; i < global.nbthread; i++)
- pthread_create(&ha_pthread[i], NULL, handler, (void *)(long)i);
+ pthread_create(&ha_pthread[i], NULL, handler, &ha_thread_info[i]);
}
/* waits for all threads to terminate. Does nothing when threads are