#ifndef __COMM_H_ #define __COMM_H_ 1 #include /* Non standard include */ #include #define SHARED_SPACE_SIZE (2 * BUF_SIZE) #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) struct communication_assoc { struct communication_assoc *next; struct communication_assoc *prev; pthread_t tid; void **shared_space; volatile int *cons_idx; volatile int *prod_idx; }; extern struct communication_assoc assoc_root; __BEGIN_DECLS extern __thread void **shared_space; extern __thread volatile int prod_idx; extern __thread volatile int cons_idx; struct communication_assoc *create_comm_assoc(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