* but may be lowered to save resources on embedded systems.
*/
#ifndef USE_THREAD
-/* threads disabled, 1 thread max */
+/* threads disabled, 1 thread max, 1 group max (note: group ids start at 1) */
#define MAX_THREADS 1
#define MAX_THREADS_MASK 1
+#define MAX_TGROUPS 1
+#define MAX_THREADS_PER_GROUP 1
+
#else
/* threads enabled, max_threads defaults to long bits */
#ifndef MAX_THREADS
#define MAX_THREADS LONGBITS
#endif
#define MAX_THREADS_MASK (~0UL >> (LONGBITS - MAX_THREADS))
+
+/* still limited to 1 group for now by default (note: group ids start at 1) */
+#ifndef MAX_TGROUPS
+#define MAX_TGROUPS 1
+#endif
+#define MAX_THREADS_PER_GROUP LONGBITS
#endif
/*
/* thread_ctx flags, for ha_thread_ctx[].flags */
#define TH_FL_STUCK 0x00000001
+/* Thread group information. This defines a base and a count of global thread
+ * IDs which belong to it, and which can be looked up into thread_info/ctx. It
+ * is set up during parsing and is stable during operation. Thread groups start
+ * at 1 so tgroup[0] describes thread group 1.
+ */
+struct tgroup_info {
+ uint base; /* first thread in this group */
+ uint count; /* number of threads in this group */
+
+ /* pad to cache line (64B) */
+ char __pad[0]; /* unused except to check remaining room */
+ char __end[0] __attribute__((aligned(64)));
+};
+
/* This structure describes all the per-thread info we need. When threads are
* disabled, it contains the same info for the single running thread. This is
* stable across all of a thread's life, and is being pointed to by the
#include <haproxy/tinfo-t.h>
/* the structs are in thread.c */
+extern struct tgroup_info ha_tgroup_info[MAX_TGROUPS];
+extern THREAD_LOCAL const struct tgroup_info *tg;
+
extern struct thread_info ha_thread_info[MAX_THREADS];
extern THREAD_LOCAL const struct thread_info *ti; /* thread_info for the current thread */
#include <haproxy/thread.h>
#include <haproxy/tools.h>
+struct tgroup_info ha_tgroup_info[MAX_TGROUPS] = { };
+THREAD_LOCAL const struct tgroup_info *tg = &ha_tgroup_info[0];
+
struct thread_info ha_thread_info[MAX_THREADS] = { };
THREAD_LOCAL const struct thread_info *ti = &ha_thread_info[0];