Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. void start_pointer(struct fsm_pointer *pointer) {
  2. if ( pointer->started != 0 ){
  3. printf("CRITICAL : A pointer must be started only once");
  4. return;
  5. }
  6. pthread_create(&pointer->thread, NULL, &pointer_loop, (void *)pointer);
  7. pointer->started = 1;
  8. }
  9.  
  10. void *pointer_loop(void * _pointer) {
  11. struct fsm_pointer * pointer = _pointer; // cast void pointer
  12. struct fsm_context init_context = {
  13. .event = event,
  14. .fnct_args = step.args,
  15. };
  16. // call pointer structure member => SEGFAULT
  17. pointer->current_step.fnct(&init_context);
  18. return NULL;
  19. }
  20.  
  21. struct fsm_pointer{
  22. pthread_t thread;
  23. pthread_mutex_t mutex_event;
  24. pthread_cond_t cond_event;
  25. struct fsm_event input_event;
  26. struct fsm_step current_step;
  27. unsigned short started;
  28. };
  29.  
  30. struct fsm_step{
  31. void (*fnct)(const struct fsm_context *);
  32. void * args;
  33. struct fsm_trans transition;
  34. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement