src/os/bsd/vm/perfMemory_bsd.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7089790_bsd_vs_linux Sdiff src/os/bsd/vm

src/os/bsd/vm/perfMemory_bsd.cpp

Print this page
rev 2698 : new bsd files


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/vmSymbols.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "os_linux.inline.hpp"
  31 #include "runtime/handles.inline.hpp"
  32 #include "runtime/perfMemory.hpp"
  33 #include "utilities/exceptions.hpp"
  34 
  35 // put OS-includes here
  36 # include <sys/types.h>
  37 # include <sys/mman.h>
  38 # include <errno.h>
  39 # include <stdio.h>
  40 # include <unistd.h>
  41 # include <sys/stat.h>
  42 # include <signal.h>
  43 # include <pwd.h>
  44 
  45 static char* backing_store_file_name = NULL;  // name of the backing store
  46                                               // file, if successfully created.
  47 
  48 // Standard Memory Implementation Details
  49 
  50 // create the PerfData memory region in standard memory.


 115         break;
 116       }
 117 
 118       remaining -= (size_t)result;
 119       addr += result;
 120     }
 121 
 122     RESTARTABLE(::close(fd), result);
 123     if (PrintMiscellaneous && Verbose) {
 124       if (result == OS_ERR) {
 125         warning("Could not close %s: %s\n", destfile, strerror(errno));
 126       }
 127     }
 128   }
 129   FREE_C_HEAP_ARRAY(char, destfile);
 130 }
 131 
 132 
 133 // Shared Memory Implementation Details
 134 
 135 // Note: the solaris and linux shared memory implementation uses the mmap
 136 // interface with a backing store file to implement named shared memory.
 137 // Using the file system as the name space for shared memory allows a
 138 // common name space to be supported across a variety of platforms. It
 139 // also provides a name space that Java applications can deal with through
 140 // simple file apis.
 141 //
 142 // The solaris and linux implementations store the backing store file in
 143 // a user specific temporary directory located in the /tmp file system,
 144 // which is always a local file system and is sometimes a RAM based file
 145 // system.
 146 
 147 // return the user specific temporary directory name.
 148 //
 149 // the caller is expected to free the allocated memory.
 150 //
 151 static char* get_user_tmp_dir(const char* user) {
 152 
 153   const char* tmpdir = os::get_temp_directory();
 154   const char* perfdir = PERFDATA_NAME;
 155   size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
 156   char* dirname = NEW_C_HEAP_ARRAY(char, nbytes);
 157 
 158   // construct the path name to user specific tmp directory
 159   snprintf(dirname, nbytes, "%s/%s_%s", tmpdir, perfdir, user);
 160 
 161   return dirname;
 162 }


 673     if (errno == ENOENT) {
 674       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 675                   "Process not found");
 676     }
 677     else if (errno == EACCES) {
 678       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 679                   "Permission denied");
 680     }
 681     else {
 682       THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
 683     }
 684   }
 685 
 686   return result;
 687 }
 688 
 689 // create a named shared memory region. returns the address of the
 690 // memory region on success or NULL on failure. A return value of
 691 // NULL will ultimately disable the shared memory feature.
 692 //
 693 // On Solaris and Linux, the name space for shared memory objects
 694 // is the file system name space.
 695 //
 696 // A monitoring application attaching to a JVM does not need to know
 697 // the file system name of the shared memory object. However, it may
 698 // be convenient for applications to discover the existence of newly
 699 // created and terminating JVMs by watching the file system name space
 700 // for files being created or removed.
 701 //
 702 static char* mmap_create_shared(size_t size) {
 703 
 704   int result;
 705   int fd;
 706   char* mapAddress;
 707 
 708   int vmid = os::current_process_id();
 709 
 710   char* user_name = get_user_name(geteuid());
 711 
 712   if (user_name == NULL)
 713     return NULL;




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/vmSymbols.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "os_bsd.inline.hpp"
  31 #include "runtime/handles.inline.hpp"
  32 #include "runtime/perfMemory.hpp"
  33 #include "utilities/exceptions.hpp"
  34 
  35 // put OS-includes here
  36 # include <sys/types.h>
  37 # include <sys/mman.h>
  38 # include <errno.h>
  39 # include <stdio.h>
  40 # include <unistd.h>
  41 # include <sys/stat.h>
  42 # include <signal.h>
  43 # include <pwd.h>
  44 
  45 static char* backing_store_file_name = NULL;  // name of the backing store
  46                                               // file, if successfully created.
  47 
  48 // Standard Memory Implementation Details
  49 
  50 // create the PerfData memory region in standard memory.


 115         break;
 116       }
 117 
 118       remaining -= (size_t)result;
 119       addr += result;
 120     }
 121 
 122     RESTARTABLE(::close(fd), result);
 123     if (PrintMiscellaneous && Verbose) {
 124       if (result == OS_ERR) {
 125         warning("Could not close %s: %s\n", destfile, strerror(errno));
 126       }
 127     }
 128   }
 129   FREE_C_HEAP_ARRAY(char, destfile);
 130 }
 131 
 132 
 133 // Shared Memory Implementation Details
 134 
 135 // Note: the solaris and bsd shared memory implementation uses the mmap
 136 // interface with a backing store file to implement named shared memory.
 137 // Using the file system as the name space for shared memory allows a
 138 // common name space to be supported across a variety of platforms. It
 139 // also provides a name space that Java applications can deal with through
 140 // simple file apis.
 141 //
 142 // The solaris and bsd implementations store the backing store file in
 143 // a user specific temporary directory located in the /tmp file system,
 144 // which is always a local file system and is sometimes a RAM based file
 145 // system.
 146 
 147 // return the user specific temporary directory name.
 148 //
 149 // the caller is expected to free the allocated memory.
 150 //
 151 static char* get_user_tmp_dir(const char* user) {
 152 
 153   const char* tmpdir = os::get_temp_directory();
 154   const char* perfdir = PERFDATA_NAME;
 155   size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
 156   char* dirname = NEW_C_HEAP_ARRAY(char, nbytes);
 157 
 158   // construct the path name to user specific tmp directory
 159   snprintf(dirname, nbytes, "%s/%s_%s", tmpdir, perfdir, user);
 160 
 161   return dirname;
 162 }


 673     if (errno == ENOENT) {
 674       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 675                   "Process not found");
 676     }
 677     else if (errno == EACCES) {
 678       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 679                   "Permission denied");
 680     }
 681     else {
 682       THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
 683     }
 684   }
 685 
 686   return result;
 687 }
 688 
 689 // create a named shared memory region. returns the address of the
 690 // memory region on success or NULL on failure. A return value of
 691 // NULL will ultimately disable the shared memory feature.
 692 //
 693 // On Solaris and Bsd, the name space for shared memory objects
 694 // is the file system name space.
 695 //
 696 // A monitoring application attaching to a JVM does not need to know
 697 // the file system name of the shared memory object. However, it may
 698 // be convenient for applications to discover the existence of newly
 699 // created and terminating JVMs by watching the file system name space
 700 // for files being created or removed.
 701 //
 702 static char* mmap_create_shared(size_t size) {
 703 
 704   int result;
 705   int fd;
 706   char* mapAddress;
 707 
 708   int vmid = os::current_process_id();
 709 
 710   char* user_name = get_user_name(geteuid());
 711 
 712   if (user_name == NULL)
 713     return NULL;


src/os/bsd/vm/perfMemory_bsd.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File