2009-06-18 14:48:07 +02:00
|
|
|
#ifndef _SPECIFIC_COMM_H_
|
|
|
|
#define _SPECIFIC_COMM_H_ 1
|
2009-06-10 09:58:50 +02:00
|
|
|
|
|
|
|
/* Non standard include */
|
2009-06-18 14:48:07 +02:00
|
|
|
#include <commtech.h>
|
2009-06-10 09:58:50 +02:00
|
|
|
|
2009-06-11 23:35:41 +02:00
|
|
|
#define SHARED_SPACE_SIZE (2 * BUF_SIZE)
|
2009-06-16 12:58:30 +02:00
|
|
|
#define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *))
|
2009-06-10 09:58:50 +02:00
|
|
|
|
2009-06-18 14:48:07 +02:00
|
|
|
struct thread_comm
|
2009-06-10 09:58:50 +02:00
|
|
|
{
|
2009-06-18 14:48:07 +02:00
|
|
|
volatile void **shared_space;
|
2009-06-12 00:36:31 +02:00
|
|
|
volatile int *cons_idx;
|
|
|
|
volatile int *prod_idx;
|
2009-06-10 09:58:50 +02:00
|
|
|
};
|
|
|
|
|
2009-06-18 14:48:07 +02:00
|
|
|
extern struct thread_comm *tcomms;
|
2009-06-10 09:58:50 +02:00
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2009-06-18 14:48:07 +02:00
|
|
|
extern __thread volatile void **shared_space;
|
2009-06-12 00:36:31 +02:00
|
|
|
extern __thread volatile int prod_idx;
|
|
|
|
extern __thread volatile int cons_idx;
|
2009-06-10 09:58:50 +02:00
|
|
|
|
2009-06-24 22:25:28 +02:00
|
|
|
int init_thread_comm(struct thread_comm *);
|
|
|
|
int end_thread_comm(void);
|
2009-06-16 13:22:08 +02:00
|
|
|
static inline void send(void **addr) {
|
2009-06-16 12:58:30 +02:00
|
|
|
while ((prod_idx + 1) % SHARED_SPACE_VOIDPTR == cons_idx);
|
|
|
|
shared_space[prod_idx] = addr;
|
|
|
|
prod_idx = (prod_idx + 1) % SHARED_SPACE_VOIDPTR;
|
2009-06-10 09:58:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif
|