void *thread_code(void *t) { int taskno = (int) t; int fifo = taskno + 1; struct my_msg_struct msg; int rt_fd, output_fd; char name[10]; msg.command = NOOP; //don't start out with //an action sprintf(name,"/dev/rtf%d",fifo); rt_fd = open(name, O_NONBLOCK); sprintf(name,"/dev/rtf%d",fifo+2); output_fd = open(name, O_NONBLOCK); pthread_make_periodic_np(pthread_self(), gethrtime(), 500000000); while (1) { pthread_wait_np(); read(rt_fd,&msg,sizeof(msg)); switch (msg.command) { case HELLO: write(output_fd, "hello ", 6); break; case WORLD: write(output_fd, "world ", 6); break; case NOOP: continue; case STOP: default: close(output_fd); close(rt_fd); return 0; } } return 0; }