39 lines
753 B
C
39 lines
753 B
C
#ifndef __COMM_H_
|
|
#define __COMM_H_ 1
|
|
|
|
#include <stdint.h>
|
|
|
|
/* Non standard include */
|
|
#include <common_comm.h>
|
|
|
|
#define SHARED_SPACE_SIZE (2 * BUF_SIZE)
|
|
|
|
struct communication_assoc
|
|
{
|
|
struct communication_assoc *next;
|
|
struct communication_assoc *prev;
|
|
pthread_t tid;
|
|
uintptr_t *shared_space;
|
|
int *cons_idx;
|
|
int *prod_idx;
|
|
};
|
|
|
|
extern struct communication_assoc assoc_root;
|
|
|
|
__BEGIN_DECLS
|
|
|
|
extern __thread uintptr_t *shared_space;
|
|
extern __thread int prod_idx;
|
|
extern __thread int cons_idx;
|
|
|
|
struct communication_assoc *create_comm_assoc(void);
|
|
static inline void send(uintptr_t value) {
|
|
while ((prod_idx + 1) % SHARED_SPACE_SIZE == cons_idx);
|
|
shared_space[prod_idx] = value;
|
|
prod_idx = (prod_idx + 1) % SHARED_SPACE_SIZE;
|
|
}
|
|
|
|
__END_DECLS
|
|
|
|
#endif
|