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
#ifdef __GNUC__
00029
#pragma interface
00030
#endif
00031
00032
#ifndef _util_group_memshm_h
00033
#define _util_group_memshm_h
00034
00035
#include <sys/types.h>
00036
#include <sys/ipc.h>
00037
#include <sys/shm.h>
00038
#include <iostream>
00039
00040
#include <util/group/globcnt.h>
00041
#include <util/group/memmsg.h>
00042
00043
#include <util/group/rnglock.h>
00044
00045
namespace sc {
00046
00050 class ShmMemoryGrp:
public MsgMemoryGrp {
00051
private:
00052
int nregion_;
00053
int *shmid_;
00054
void **attach_address_;
00055 GlobalCounter lock_;
00056 GlobalCounter *update_;
00057
void *data_;
00058
void *memory_;
00059 Pool *pool_;
00060 RangeLock *rangelock_;
00061
00062
void clear_release_count();
00063
void wait_for_release();
00064
void note_release();
00065
void obtain_lock();
00066
void release_lock();
00067
00068
void cleanup();
00069
int attach_memory(
void *ataddress,
int size);
00070
void detach_memory();
00071
public:
00072
ShmMemoryGrp(
const Ref<MessageGrp>& msg);
00073
ShmMemoryGrp(
const Ref<KeyVal>&);
00074 ~
ShmMemoryGrp();
00075
00076
void set_localsize(size_t);
00077
void *
localdata();
00078
00079
void *
obtain_readwrite(distsize_t offset,
int size);
00080
void *
obtain_readonly(distsize_t offset,
int size);
00081
void *
obtain_writeonly(distsize_t offset,
int size);
00082
void release_readonly(
void *data, distsize_t offset,
int size);
00083
void release_writeonly(
void *data, distsize_t offset,
int size);
00084
void release_readwrite(
void *data, distsize_t offset,
int size);
00085
00086
void print(std::ostream &o = ExEnv::out0())
const;
00087 };
00088
00089 }
00090
00091
#endif
00092
00093
00094
00095
00096