thread.h 891 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __THREAD_Hx__
  2. #define __THREAD_Hx__
  3. #include <pthread.h>
  4. #include <stdio.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #define KB 1024
  9. #define MB (1024*1024)
  10. enum {
  11. THREAD_ID_IO=0,
  12. THREAD_ID_WS,
  13. THREAD_ID_WEB,
  14. THREAD_ID_NTP,
  15. THREAD_ID_SNMP,
  16. THREAD_ID_POWER,
  17. THREAD_ID_SENSOR,
  18. THREAD_ID_PLUG,
  19. THREAD_ID_CASCADE,
  20. THREAD_ID_SCAN,
  21. THREAD_ID_SHMW,
  22. THREAD_ID_BREAKER,
  23. THREAD_ID_SWITCH,
  24. THREAD_ID_MAX=30
  25. };
  26. typedef void *(*thread_fn)(void *arg);
  27. typedef struct {
  28. pthread_t tid;
  29. int quit;
  30. void *arg;
  31. thread_fn fn;
  32. }thread_handle_t;
  33. int thread_start(int id, thread_fn fn, void *arg, int stksize, int prio);
  34. int thread_stop(int id);
  35. int thread_stop_all(void);
  36. int thread_start_simp(thread_fn fn, void *arg, int stksize);
  37. int thread_print_stacksize(void);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif