UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
memctl.H
Go to the documentation of this file.
1 /* memctl.H */
2 /* $Id: memctl.H,v 1.3 2003/03/17 10:03:16 vlad Exp $ */
3 #ifndef __memctl_H
4 #define __memctl_H
5 
6 #include <csi/pep_defs.h>
7 #include <csi/pep_ipc.H>
8 
27 class MemBlock
28 {
29 public:
30 
32  virtual ~MemBlock ();
33 
35  virtual size_t size () = 0;
36 
39  virtual void resize (size_t volume) = 0;
40 
42  virtual void* ptr () = 0;
43 
45  virtual void operator= (MemBlock& mem_blk);
46 
47 };
48 
49 
54 class LocalMem : public MemBlock
55 {
56 private:
57 
58  void *address;
59  size_t blk_size;
61 public:
62 
63  LocalMem (size_t volume);
64  LocalMem (size_t volume, void* p);
65 
67  virtual ~LocalMem ();
68 
70  virtual size_t size ()
71  { return blk_size; }
72 
75  virtual void resize (size_t volume);
76 
78  virtual void* ptr ();
79 
80 };
81 
82 
87 class SharedMem : public ObjectIPC, public MemBlock
88 {
89 private:
90 
91  void* address;
92  int shm_id;
94 protected:
95 
96 #if !PEP_USE_SHM_SIZE
97 
98  void coherency ();
99 #endif /* !SHM_SIZE */
100 
101 public:
102 
103  SharedMem (size_t volume);
104  SharedMem (size_t volume, key_t shm_k);
107  virtual ~SharedMem ();
108 
110  virtual size_t size ();
111 
114  virtual void resize (size_t volume);
115 
117  virtual void* ptr ();
118 
120  virtual int attach_cnt ();
121 
122 };
123 
124 
129 enum MemPolicy {
132 };
133 
134 
135 class TableUDC; /* forward declaration */
136 
142 class UniMem : public MemBlock
143 {
144  friend class TableUDC;
145 
146 private:
147 
148  TableUDC *host;
149  int udc_i;
150  MemBlock *udc_mem;
152  UniMem (TableUDC *tbl, int index);
153  UniMem (UniMem& unimem);
154 
155 public:
156 
158  virtual ~UniMem ();
159 
161  virtual size_t size ();
162 
165  virtual void resize (size_t volume);
166 
168  virtual void* ptr ();
169 
170 };
171 
172 
181 {
182  size_t v_size;
183  union {
184  key_t k_ref;
185  void *p_ref;
186  char buf[PEP_UDC_FIXED_SIZE];
187  } v;
188 };
189 
190 
198 class TableUDC : public ObjectIPC
199 {
200  friend class UniMem;
201 
202 private:
203 
204  /* *** are not changed after construction *** */
205  MemPolicy policy;
206  UniDataCell *cells;
207  int ncells;
208  MemBlock *cells_mem;
209  UniMem **cell_mem;
211 public:
212 
213  TableUDC (key_t k_udc);
214  TableUDC (int udc_cnt, MemPolicy mp);
215  virtual ~TableUDC ();
216 
218  int udc_count ()
219  { return ncells; }
220 
222  UniMem* operator[] (int udc_i);
223 
225  virtual key_t key ();
226 
228  virtual int attach_cnt ();
229 
230 };
231 
232 
233 #endif /* memctl.H */
Definition: memctl.H:130
virtual size_t size()
Definition: memctl.H:70
virtual void resize(size_t volume)
virtual void * ptr()
virtual int attach_cnt()
Definition: memctl.H:142
char buf[PEP_UDC_FIXED_SIZE]
Definition: memctl.H:186
virtual void resize(size_t volume)=0
Definition: pep_ipc.H:14
UniMem * operator[](int udc_i)
TableUDC(key_t k_udc)
int udc_count()
Definition: memctl.H:218
virtual void resize(size_t volume)
void coherency()
Definition: memctl.H:54
virtual ~LocalMem()
virtual size_t size()
SharedMem(size_t volume)
virtual void resize(size_t volume)
virtual ~MemBlock()
MemPolicy
Definition: memctl.H:129
virtual void * ptr()=0
virtual size_t size()
Definition: memctl.H:180
virtual ~SharedMem()
virtual void * ptr()
Definition: memctl.H:27
virtual void * ptr()
key_t k_ref
Definition: memctl.H:184
void * p_ref
Definition: memctl.H:185
Definition: memctl.H:131
virtual key_t key()
Definition: memctl.H:87
virtual int attach_cnt()
virtual size_t size()=0
virtual void operator=(MemBlock &mem_blk)
Definition: memctl.H:198
size_t v_size
Definition: memctl.H:182
union UniDataCell::@0 v
virtual ~UniMem()