|
memshm.h00001 // 00002 // memshm.h 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 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_; // the locks_ member of the base class is ignored 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 // Local Variables: 00094 // mode: c++ 00095 // c-file-style: "CLJ" 00096 // End: Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14. |