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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <vpr/vprConfig.h>
00043
00044 #include <vpr/md/SPROC/SharedMem/MemPool.h>
00045
00046
00047 usptr_t* vpr::MemPoolSGI::arenaForMemPools = NULL;
00048 char* vpr::MemPoolSGI::arenaForMemPoolsFileName = NULL;
00049
00050
00051 vpr::MemPoolSGI::MemPoolSGI (size_t initialSize, int numProcs,
00052 char* staticTempName)
00053 {
00054 std::cerr.setf(std::ios::showbase);
00055 std::cerr << "\nMemPoolSGI: Allocating arena (" << initialSize << " bytes, "
00056 << numProcs << " procs, " << std::hex << this << std::dec
00057 << ")\n" << std::flush;
00058
00059 usconfig(CONF_INITUSERS, numProcs);
00060 usconfig(CONF_INITSIZE, initialSize);
00061 usconfig(CONF_AUTOGROW, 1);
00062
00063 usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);
00064
00065
00066
00067 char* tempName = new char[strlen(staticTempName)+1];
00068 strcpy(tempName, staticTempName);
00069
00070 arena = usinit(mktemp(tempName));
00071
00072 arenaFileName = tempName;
00073
00074
00075 if ( arena == NULL )
00076 {
00077 perror("ERROR: PoolSGI::MemPoolSGI");
00078 }
00079
00080 std::cerr << " " << arenaFileName << ", " << "arena: " << std::hex << arena
00081 << std::dec << std::endl;
00082 std::cerr.unsetf(std::ios::showbase);
00083 }
00084
00085 void vpr::MemPoolSGI::init (size_t initialSize, int numProcs,
00086 char* staticTempName)
00087 {
00088 if ( arenaForMemPools == NULL )
00089 {
00090 std::cerr << "\nMemPoolSGI: Allocating Base Arena for ALL MemPoolSGI's.\n"
00091 << initialSize << " bytes, " << numProcs << " procs"
00092 << "\n" << std::flush;
00093
00094 usconfig(CONF_INITUSERS, numProcs);
00095 usconfig(CONF_INITSIZE, initialSize);
00096 usconfig(CONF_AUTOGROW, 1);
00097
00098 char* tempName = strdup (staticTempName);
00099
00100 arenaForMemPools = usinit(mktemp(tempName));
00101 unlink(tempName);
00102
00103 if ( arenaForMemPools == NULL )
00104 {
00105 perror("ERROR: MemPoolSGI::init. Was not able to get an arena!!!!");
00106 }
00107 arenaForMemPoolsFileName = (char*)usmalloc(strlen(staticTempName)+1, arenaForMemPools);
00108 strcpy(arenaForMemPoolsFileName, tempName);
00109 free (tempName);
00110
00111 std::cerr.setf(std::ios::showbase);
00112 std::cerr << " " << arenaForMemPoolsFileName << ", " << "arena: "
00113 << std::hex << arenaForMemPools << std::dec << std::endl;
00114 std::cerr.unsetf(std::ios::showbase);
00115 }
00116 else
00117 {
00118 std::cerr << "Tried to re-init the Base Arena for ALL MemPoolSGI's"
00119 << std::endl;
00120 }
00121 }