#ifndef _SPECIFIC_COMM_H_ #define _SPECIFIC_COMM_H_ 1 /* Non standard include */ #include #include #define SHARED_SPACE_SIZE (16 * BUF_SIZE) #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) #define DANGER (2 * BUF_SIZE / sizeof(void *)) #define GOOD (6 * BUF_SIZE / sizeof(void *)) #define ADJUST_FREQ 64 struct comm { void * volatile *shared_space; int head; int tail; }; __BEGIN_DECLS extern __thread struct comm *comm; extern int adjust_slip(void); static inline void send(void **addr) { static __thread int nb_iter = 0; assert(addr != NULL); if (nb_iter == ADJUST_FREQ) { adjust_slip(); nb_iter = 0; } while (1) { if (comm->shared_space[comm->head] != NULL) continue; comm->shared_space[comm->head] = addr; comm->head = (comm->head + 1) % SHARED_SPACE_VOIDPTR; break; } } __END_DECLS #endif