00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#ifndef _util_group_messshm_h
00029
#define _util_group_messshm_h
00030
00031
#include <unistd.h>
00032
#include <sys/types.h>
00033
#include <sys/ipc.h>
00034
#include <sys/sem.h>
00035
#include <sys/shm.h>
00036
00037
#include <util/group/message.h>
00038
00039
namespace sc {
00040
00041
#define SHMCOMMBUFSIZE 1500000
00042
00043
00044
#define MAXPROCS 17
00045
00046
00047
struct commbuf_struct {
00048
int nmsg;
00049
int n_wait_for_change;
00050
int n_sync;
00051
char buf[SHMCOMMBUFSIZE];
00052 };
00053
typedef struct commbuf_struct commbuf_t;
00054
00055
struct msgbuf_struct {
00056
int type;
00057
int from;
00058
int size;
00059 };
00060
typedef struct msgbuf_struct msgbuf_t;
00061
00068 class ShmMessageGrp:
public intMessageGrp {
00069
protected:
00070
void basic_send(
int target,
int type,
void* data,
int nbyte);
00071
void basic_recv(
int type,
void* data,
int nbyte);
00072
int basic_probe(
int type);
00073
void initialize(
int nprocs);
00074
void initialize();
00075
00076
00077 commbuf_t *commbuf[MAXPROCS];
00078
int shmid;
00079
int semid;
00080
int change_semid;
00081
void* sharedmem;
00082
struct sembuf semdec;
00083
struct sembuf seminc;
00084
00085
00086 msgbuf_t *NEXT_MESSAGE(msgbuf_t *m);
00087
void get_change(
int node);
00088
void put_change(
int node);
00089
void wait_for_write(
int node);
00090
void release_write(
int node);
00091
#ifdef DEBUG
00092
void print_buffer(
int node,
int me);
00093
#endif
00094
public:
00096
ShmMessageGrp();
00106
ShmMessageGrp(
const Ref<KeyVal>&);
00108
ShmMessageGrp(
int nprocs);
00109 ~
ShmMessageGrp();
00110
void sync();
00111
00112
Ref<MessageGrp> clone(
void);
00113 };
00114
00115 }
00116
00117
#endif
00118
00119
00120
00121
00122