root/juggler/branches/1.0/SharedMem/vjMemPoolSGI.cpp

Revision 8789, 4.1 kB (checked in by patrickh, 7 years ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998, 1999, 2000, 2001, 2002
4  *   by Iowa State University
5  *
6  * Original Authors:
7  *   Allen Bierbaum, Christopher Just,
8  *   Patrick Hartling, Kevin Meinert,
9  *   Carolina Cruz-Neira, Albert Baker
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the
23  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  *
26  * -----------------------------------------------------------------
27  * File:          $RCSfile$
28  * Date modified: $Date$
29  * Version:       $Revision$
30  * -----------------------------------------------------------------
31  *
32  *************** <auto-copyright.pl END do not edit this line> ***************/
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);   // Default, but we set anyway
57 //#ifdef DEBUG_VJ
58    usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);    // what type of lock information
59 //#endif
60
61    //static char* staticTempName = "/var/tmp/memPoolSGIXXXXXX";  // Do it this way because mktemp overwrite's the variable
62    char* tempName = new char[strlen(staticTempName)+1];      // Therefore we need to use a non-static variable
63    strcpy(tempName, staticTempName);
64
65    arena = usinit(mktemp(tempName));   // Allocate the arena
66
67    arenaFileName = tempName;      // So we know where the file is
68    //delete tempName;               // Delete the temporary file name
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);   // Default, but we set anyway
93   
94       char* tempName = strdup (staticTempName); // make mutable copy for mktemp
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 }
Note: See TracBrowser for help on using the browser.