#ifndef _SPECIFIC_COMM_H_ #define _SPECIFIC_COMM_H_ 1 /* Non standard include */ #include #define SHARED_SPACE_SIZE (2 * BUF_SIZE) #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) struct thread_comm { volatile void **shared_space; volatile int *cons_idx; volatile int *prod_idx; }; extern struct thread_comm *tcomms; __BEGIN_DECLS extern __thread volatile void **shared_space; extern __thread volatile int prod_idx; extern __thread volatile int cons_idx; int init_thread_comm(struct thread_comm *); int end_thread_comm(void); static inline void send(void **addr) { while ((prod_idx + 1) % SHARED_SPACE_VOIDPTR == cons_idx); shared_space[prod_idx] = addr; prod_idx = (prod_idx + 1) % SHARED_SPACE_VOIDPTR; } __END_DECLS #endif