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
00048 class ShmMemoryGrp: public MsgMemoryGrp {
00049 private:
00050 int nregion_;
00051 int *shmid_;
00052 void **attach_address_;
00053 GlobalCounter lock_;
00054 GlobalCounter *update_;
00055 void *data_;
00056 void *memory_;
00057 Pool *pool_;
00058 RangeLock *rangelock_;
00059
00060 void clear_release_count();
00061 void wait_for_release();
00062 void note_release();
00063 void obtain_lock();
00064 void release_lock();
00065
00066 void cleanup();
00067 int attach_memory(void *ataddress, int size);
00068 void detach_memory();
00069 public:
00070 ShmMemoryGrp(const Ref<MessageGrp>& msg);
00071 ShmMemoryGrp(const Ref<KeyVal>&);
00072 ~ShmMemoryGrp();
00073
00074 void set_localsize(int);
00075 void *localdata();
00076
00077 void *obtain_readwrite(distsize_t offset, int size);
00078 void *obtain_readonly(distsize_t offset, int size);
00079 void *obtain_writeonly(distsize_t offset, int size);
00080 void release_readonly(void *data, distsize_t offset, int size);
00081 void release_writeonly(void *data, distsize_t offset, int size);
00082 void release_readwrite(void *data, distsize_t offset, int size);
00083
00084 void print(std::ostream &o = ExEnv::out()) const;
00085 };
00086
00087 #endif
00088
00089
00090
00091
00092