Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void start_pointer(struct fsm_pointer *pointer) {
- if ( pointer->started != 0 ){
- printf("CRITICAL : A pointer must be started only once");
- return;
- }
- pthread_create(&pointer->thread, NULL, &pointer_loop, (void *)pointer);
- pointer->started = 1;
- }
- void *pointer_loop(void * _pointer) {
- struct fsm_pointer * pointer = _pointer; // cast void pointer
- struct fsm_context init_context = {
- .event = event,
- .fnct_args = step.args,
- };
- // call pointer structure member => SEGFAULT
- pointer->current_step.fnct(&init_context);
- return NULL;
- }
- struct fsm_pointer{
- pthread_t thread;
- pthread_mutex_t mutex_event;
- pthread_cond_t cond_event;
- struct fsm_event input_event;
- struct fsm_step current_step;
- unsigned short started;
- };
- struct fsm_step{
- void (*fnct)(const struct fsm_context *);
- void * args;
- struct fsm_trans transition;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement