| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
#include <vjConfig.h> |
|---|
| 36 |
|
|---|
| 37 |
#include <SharedMem/vjMemPool.h> |
|---|
| 38 |
#include <SharedMem/vjMemPoolSGI.h> |
|---|
| 39 |
|
|---|
| 40 |
usptr_t* vjMemPoolSGI::arenaForMemPools = NULL; |
|---|
| 41 |
char* vjMemPoolSGI::arenaForMemPoolsFileName = NULL; |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
vjMemPoolSGI::vjMemPoolSGI (size_t initialSize, int numProcs, |
|---|
| 45 |
char* staticTempName) |
|---|
| 46 |
{ |
|---|
| 47 |
std::cerr.setf(std::ios::showbase); |
|---|
| 48 |
std::cerr << "\nvjMemPoolSGI: Allocating arena (" |
|---|
| 49 |
<< initialSize << " bytes, " |
|---|
| 50 |
<< numProcs << " procs, " |
|---|
| 51 |
<< std::hex << this << std::dec |
|---|
| 52 |
<< ")\n" << std::flush; |
|---|
| 53 |
|
|---|
| 54 |
usconfig(CONF_INITUSERS, numProcs); |
|---|
| 55 |
usconfig(CONF_INITSIZE, initialSize); |
|---|
| 56 |
usconfig(CONF_AUTOGROW, 1); |
|---|
| 57 |
|
|---|
| 58 |
usconfig(CONF_LOCKTYPE, US_DEBUGPLUS); |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
char* tempName = new char[strlen(staticTempName)+1]; |
|---|
| 63 |
strcpy(tempName, staticTempName); |
|---|
| 64 |
|
|---|
| 65 |
arena = usinit(mktemp(tempName)); |
|---|
| 66 |
|
|---|
| 67 |
arenaFileName = tempName; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
if (arena == NULL) |
|---|
| 71 |
{ |
|---|
| 72 |
perror("ERROR: vjMemPoolSGI::MemPoolSGI"); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
std::cerr << " " << arenaFileName << ", " |
|---|
| 76 |
<< "arena: " << std::hex << arena << std::dec << std::endl; |
|---|
| 77 |
std::cerr.unsetf(std::ios::showbase); |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
void |
|---|
| 81 |
vjMemPoolSGI::init (size_t initialSize, int numProcs, char* staticTempName) { |
|---|
| 82 |
if (arenaForMemPools == NULL) |
|---|
| 83 |
{ |
|---|
| 84 |
std::cerr << "\nMemPoolSGI: Allocating Base Arena for ALL " |
|---|
| 85 |
<< "vjMemPoolSGI's.\n " |
|---|
| 86 |
<< initialSize << " bytes, " |
|---|
| 87 |
<< numProcs << " procs" |
|---|
| 88 |
<< "\n" << std::flush; |
|---|
| 89 |
|
|---|
| 90 |
usconfig(CONF_INITUSERS, numProcs); |
|---|
| 91 |
usconfig(CONF_INITSIZE, initialSize); |
|---|
| 92 |
usconfig(CONF_AUTOGROW, 1); |
|---|
| 93 |
|
|---|
| 94 |
char* tempName = strdup (staticTempName); |
|---|
| 95 |
|
|---|
| 96 |
arenaForMemPools = usinit(mktemp(tempName)); |
|---|
| 97 |
unlink(tempName); |
|---|
| 98 |
|
|---|
| 99 |
if (arenaForMemPools == NULL) |
|---|
| 100 |
{ |
|---|
| 101 |
perror("ERROR: vjMemPoolSGI::init. Was not able to get an arena!!!!"); |
|---|
| 102 |
} |
|---|
| 103 |
arenaForMemPoolsFileName = (char*)usmalloc(strlen(staticTempName)+1, arenaForMemPools); |
|---|
| 104 |
strcpy(arenaForMemPoolsFileName, tempName); |
|---|
| 105 |
free (tempName); |
|---|
| 106 |
|
|---|
| 107 |
std::cerr.setf(std::ios::showbase); |
|---|
| 108 |
std::cerr << " " << arenaForMemPoolsFileName << ", " |
|---|
| 109 |
<< "arena: " << std::hex << arenaForMemPools << std::dec |
|---|
| 110 |
<< std::endl; |
|---|
| 111 |
std::cerr.unsetf(std::ios::showbase); |
|---|
| 112 |
} else { |
|---|
| 113 |
std::cerr << "Tried to re-init the Base Arena for ALL vjMemPoolSGI's" |
|---|
| 114 |
<< std::endl; |
|---|
| 115 |
} |
|---|
| 116 |
} |
|---|