#ifndef _COMMON_HATHREADS_H
#define _COMMON_HATHREADS_H
+#include <signal.h>
#include <unistd.h>
#ifdef _POSIX_PRIORITY_SCHEDULING
#include <sched.h>
#endif
}
+/* send signal <sig> to thread <thr> */
+static inline void ha_tkill(unsigned int thr, int sig)
+{
+ raise(sig);
+}
+
+/* send signal <sig> to all threads */
+static inline void ha_tkillall(int sig)
+{
+ raise(sig);
+}
+
static inline void __ha_barrier_atomic_load(void)
{
}
void thread_harmless_till_end();
void thread_isolate();
void thread_release();
+void ha_tkill(unsigned int thr, int sig);
+void ha_tkillall(int sig);
extern struct thread_info {
pthread_t pthread;
thread_harmless_end();
}
+/* send signal <sig> to thread <thr> */
+void ha_tkill(unsigned int thr, int sig)
+{
+ pthread_kill(thread_info[thr].pthread, sig);
+}
+
+/* send signal <sig> to all threads. The calling thread is signaled last in
+ * order to allow all threads to synchronize in the handler.
+ */
+void ha_tkillall(int sig)
+{
+ unsigned int thr;
+
+ for (thr = 0; thr < global.nbthread; thr++) {
+ if (!(all_threads_mask & (1UL << thr)))
+ continue;
+ if (thr == tid)
+ continue;
+ pthread_kill(thread_info[thr].pthread, sig);
+ }
+ raise(sig);
+}
+
/* these calls are used as callbacks at init time */
void ha_spin_init(HA_SPINLOCK_T *l)
{