37 lines
878 B
C
37 lines
878 B
C
#ifndef _BATCH_QUEUE_COMMON_COMM_H_
|
|
#define _BATCH_QUEUE_COMMON_COMM_H_ 1
|
|
|
|
/* Non standard include */
|
|
#include <commtech.h>
|
|
|
|
#ifndef BUF_SIZE
|
|
#define BUF_SIZE (32 * CACHE_LINE_SIZE)
|
|
#endif
|
|
|
|
struct channel
|
|
{
|
|
void * volatile buf[2 * BUF_SIZE / sizeof(void *)] __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
int unused[20] __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
volatile int state __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
int sender_idx __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
int receiver_idx __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
};
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
static inline void send(struct channel *channel, void **addr)
|
|
{
|
|
channel->buf[channel->sender_idx++] = addr;
|
|
channel->sender_idx %= 2 * (BUF_SIZE / sizeof(void *));
|
|
if (!(channel->sender_idx % (BUF_SIZE / sizeof(void *))))
|
|
{
|
|
while (channel->state);
|
|
channel->state = 1;
|
|
}
|
|
}
|
|
|
|
__END_DECLS
|
|
|
|
#endif
|