Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

memshm.h

00001 //
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 
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_; // the locks_ member of the base class is ignored
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 // Local Variables:
00090 // mode: c++
00091 // c-file-style: "CLJ"
00092 // End:

Generated at Thu Oct 4 18:08:45 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.