Pthread pause based on pthread user data
[mirrors/Programs.git] / c / pthread_extra / pthread_extra.h
index e1fe782cec638133d401592152c7c582644e7a59..0652e0a568e146bc71844db1477f1c11f57b5a97 100644 (file)
@@ -2,13 +2,46 @@
 #define __PTHREAD_EXTRA_H__
 
 #include <pthread.h>
-#include <time.h>
 #include <stdbool.h>
 #include <stdint.h>
+#include <signal.h>
+//#include <time.h>
 
 #define PTHREAD_XTIME_NOBLOCK (&(struct timespec){ .tv_sec = 0, .tv_nsec = 0 })
 #define PTHREAD_XTIME_FOREVER NULL
 
+// User data
+
+#define PTHREAD_XTHREADS_MAX 65535
+#define PTHREAD_XNULL ((pthread_t)NULL)
+
+#ifdef __PTHREAD_EXTRA_INTERNAL
+typedef struct pthread_user_data_internal_t {
+       pthread_t tid; //Thread ID
+       sig_atomic_t running; //Internaly used by pthread_pause
+       void *usr; //User pointer
+} pthread_user_data_internal_t;
+
+pthread_user_data_internal_t* pthread_user_data_internal(pthread_t thread);
+#endif //__PTHREAD_EXTRA_INTERNAL
+
+void** pthread_user_data_ptr(pthread_t thread);
+void*  pthread_user_data_get(pthread_t thread);
+void   pthread_user_data_set(pthread_t thread, void *usr);
+
+// Pausing
+
+//GDB: handle SIG34 nostop noprint
+#define PTHREAD_XSIG_STOP (SIGRTMIN+0)
+#define PTHREAD_XSIG_CONT (SIGRTMIN+1)
+#define PTHREAD_XSIGRTMIN (SIGRTMIN+2) //First unused RT signal
+
+void pthread_unpause_handler();
+void pthread_pause_handler();
+void pthread_pause_enable();
+int pthread_pause(pthread_t thread);
+int pthread_unpause(pthread_t thread);
+
 // Message queues
 
 #define PTHREAD_XMQ_FRONT true
This page took 0.131775 seconds and 4 git commands to generate.