src/hotspot/os/aix/os_aix.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 55044 d3afe760b392
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
   130 #define ERROR_MP_EXTSHM_ACTIVE                       101
   130 #define ERROR_MP_EXTSHM_ACTIVE                       101
   131 #define ERROR_MP_VMGETINFO_FAILED                    102
   131 #define ERROR_MP_VMGETINFO_FAILED                    102
   132 #define ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K 103
   132 #define ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K 103
   133 
   133 
   134 // excerpts from systemcfg.h that might be missing on older os levels
   134 // excerpts from systemcfg.h that might be missing on older os levels
   135 #ifndef PV_5_Compat
       
   136   #define PV_5_Compat 0x0F8000   /* Power PC 5 */
       
   137 #endif
       
   138 #ifndef PV_6
       
   139   #define PV_6 0x100000          /* Power PC 6 */
       
   140 #endif
       
   141 #ifndef PV_6_1
       
   142   #define PV_6_1 0x100001        /* Power PC 6 DD1.x */
       
   143 #endif
       
   144 #ifndef PV_6_Compat
       
   145   #define PV_6_Compat 0x108000   /* Power PC 6 */
       
   146 #endif
       
   147 #ifndef PV_7
   135 #ifndef PV_7
   148   #define PV_7 0x200000          /* Power PC 7 */
   136   #define PV_7 0x200000          /* Power PC 7 */
   149 #endif
   137 #endif
   150 #ifndef PV_7_Compat
   138 #ifndef PV_7_Compat
   151   #define PV_7_Compat 0x208000   /* Power PC 7 */
   139   #define PV_7_Compat 0x208000   /* Power PC 7 */
   154   #define PV_8 0x300000          /* Power PC 8 */
   142   #define PV_8 0x300000          /* Power PC 8 */
   155 #endif
   143 #endif
   156 #ifndef PV_8_Compat
   144 #ifndef PV_8_Compat
   157   #define PV_8_Compat 0x308000   /* Power PC 8 */
   145   #define PV_8_Compat 0x308000   /* Power PC 8 */
   158 #endif
   146 #endif
       
   147 #ifndef PV_9
       
   148   #define PV_9 0x400000          /* Power PC 9 */
       
   149 #endif
       
   150 #ifndef PV_9_Compat
       
   151   #define PV_9_Compat  0x408000  /* Power PC 9 */
       
   152 #endif
       
   153 
   159 
   154 
   160 static address resolve_function_descriptor_to_code_pointer(address p);
   155 static address resolve_function_descriptor_to_code_pointer(address p);
   161 
   156 
   162 static void vmembk_print_on(outputStream* os);
   157 static void vmembk_print_on(outputStream* os);
   163 
   158 
   485       struct shmid_ds shm_buf = { 0 };
   480       struct shmid_ds shm_buf = { 0 };
   486       shm_buf.shm_pagesize = pagesize;
   481       shm_buf.shm_pagesize = pagesize;
   487       if (::shmctl(shmid, SHM_PAGESIZE, &shm_buf) != 0) {
   482       if (::shmctl(shmid, SHM_PAGESIZE, &shm_buf) != 0) {
   488         const int en = errno;
   483         const int en = errno;
   489         ::shmctl(shmid, IPC_RMID, NULL); // As early as possible!
   484         ::shmctl(shmid, IPC_RMID, NULL); // As early as possible!
   490         trcVerbose("shmctl(SHM_PAGESIZE) failed with errno=%n",
   485         trcVerbose("shmctl(SHM_PAGESIZE) failed with errno=%d", errno);
   491           errno);
       
   492       } else {
   486       } else {
   493         // Attach and double check pageisze.
   487         // Attach and double check pageisze.
   494         void* p = ::shmat(shmid, NULL, 0);
   488         void* p = ::shmat(shmid, NULL, 0);
   495         ::shmctl(shmid, IPC_RMID, NULL); // As early as possible!
   489         ::shmctl(shmid, IPC_RMID, NULL); // As early as possible!
   496         guarantee0(p != (void*) -1); // Should always work.
   490         guarantee0(p != (void*) -1); // Should always work.
   497         const size_t real_pagesize = os::Aix::query_pagesize(p);
   491         const size_t real_pagesize = os::Aix::query_pagesize(p);
   498         if (real_pagesize != pagesize) {
   492         if (real_pagesize != pagesize) {
   499           trcVerbose("real page size (0x%llX) differs.", real_pagesize);
   493           trcVerbose("real page size (" SIZE_FORMAT_HEX ") differs.", real_pagesize);
   500         } else {
   494         } else {
   501           can_use = true;
   495           can_use = true;
   502         }
   496         }
   503         ::shmdt(p);
   497         ::shmdt(p);
   504       }
   498       }
   522       describe_pagesize(g_multipage_support.textpsize));
   516       describe_pagesize(g_multipage_support.textpsize));
   523   trcVerbose("Thread stack page size (pthread): %s",
   517   trcVerbose("Thread stack page size (pthread): %s",
   524       describe_pagesize(g_multipage_support.pthr_stack_pagesize));
   518       describe_pagesize(g_multipage_support.pthr_stack_pagesize));
   525   trcVerbose("Default shared memory page size: %s",
   519   trcVerbose("Default shared memory page size: %s",
   526       describe_pagesize(g_multipage_support.shmpsize));
   520       describe_pagesize(g_multipage_support.shmpsize));
   527   trcVerbose("Can use 64K pages dynamically with shared meory: %s",
   521   trcVerbose("Can use 64K pages dynamically with shared memory: %s",
   528       (g_multipage_support.can_use_64K_pages ? "yes" :"no"));
   522       (g_multipage_support.can_use_64K_pages ? "yes" :"no"));
   529   trcVerbose("Can use 16M pages dynamically with shared memory: %s",
   523   trcVerbose("Can use 16M pages dynamically with shared memory: %s",
   530       (g_multipage_support.can_use_16M_pages ? "yes" :"no"));
   524       (g_multipage_support.can_use_16M_pages ? "yes" :"no"));
   531   trcVerbose("Multipage error details: %d",
   525   trcVerbose("Multipage error details: %d",
   532       g_multipage_support.error);
   526       g_multipage_support.error);
   553   // Note that the space for the trailing null is provided
   547   // Note that the space for the trailing null is provided
   554   // by the nulls included by the sizeof operator.
   548   // by the nulls included by the sizeof operator.
   555   const size_t bufsize =
   549   const size_t bufsize =
   556     MAX2((size_t)MAXPATHLEN,  // For dll_dir & friends.
   550     MAX2((size_t)MAXPATHLEN,  // For dll_dir & friends.
   557          (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR)); // extensions dir
   551          (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR)); // extensions dir
   558   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
   552   char *buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
   559 
   553 
   560   // sysclasspath, java_home, dll_dir
   554   // sysclasspath, java_home, dll_dir
   561   {
   555   {
   562     char *pslash;
   556     char *pslash;
   563     os::jvm_path(buf, bufsize);
   557     os::jvm_path(buf, bufsize);
   595   const char *v_colon = ":";
   589   const char *v_colon = ":";
   596   if (v == NULL) { v = ""; v_colon = ""; }
   590   if (v == NULL) { v = ""; v_colon = ""; }
   597 
   591 
   598   // Concatenate user and invariant part of ld_library_path.
   592   // Concatenate user and invariant part of ld_library_path.
   599   // That's +1 for the colon and +1 for the trailing '\0'.
   593   // That's +1 for the colon and +1 for the trailing '\0'.
   600   char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, strlen(v) + 1 + sizeof(DEFAULT_LIBPATH) + 1, mtInternal);
   594   char *ld_library_path = NEW_C_HEAP_ARRAY(char, strlen(v) + 1 + sizeof(DEFAULT_LIBPATH) + 1, mtInternal);
   601   sprintf(ld_library_path, "%s%s" DEFAULT_LIBPATH, v, v_colon);
   595   sprintf(ld_library_path, "%s%s" DEFAULT_LIBPATH, v, v_colon);
   602   Arguments::set_library_path(ld_library_path);
   596   Arguments::set_library_path(ld_library_path);
   603   FREE_C_HEAP_ARRAY(char, ld_library_path);
   597   FREE_C_HEAP_ARRAY(char, ld_library_path);
   604 
   598 
   605   // Extensions directories.
   599   // Extensions directories.
  1026 // time support
  1020 // time support
  1027 
  1021 
  1028 // Time since start-up in seconds to a fine granularity.
  1022 // Time since start-up in seconds to a fine granularity.
  1029 // Used by VMSelfDestructTimer and the MemProfiler.
  1023 // Used by VMSelfDestructTimer and the MemProfiler.
  1030 double os::elapsedTime() {
  1024 double os::elapsedTime() {
  1031   return (double)(os::elapsed_counter()) * 0.000001;
  1025   return ((double)os::elapsed_counter()) / os::elapsed_frequency(); // nanosecond resolution
  1032 }
  1026 }
  1033 
  1027 
  1034 jlong os::elapsed_counter() {
  1028 jlong os::elapsed_counter() {
  1035   timeval time;
  1029   return javaTimeNanos() - initial_time_count;
  1036   int status = gettimeofday(&time, NULL);
       
  1037   return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count;
       
  1038 }
  1030 }
  1039 
  1031 
  1040 jlong os::elapsed_frequency() {
  1032 jlong os::elapsed_frequency() {
  1041   return (1000 * 1000);
  1033   return NANOSECS_PER_SEC; // nanosecond resolution
  1042 }
  1034 }
  1043 
  1035 
  1044 bool os::supports_vtime() { return true; }
  1036 bool os::supports_vtime() { return true; }
  1045 bool os::enable_vtime()   { return false; }
       
  1046 bool os::vtime_enabled()  { return false; }
       
  1047 
  1037 
  1048 double os::elapsedVTime() {
  1038 double os::elapsedVTime() {
  1049   struct rusage usage;
  1039   struct rusage usage;
  1050   int retval = getrusage(RUSAGE_THREAD, &usage);
  1040   int retval = getrusage(RUSAGE_THREAD, &usage);
  1051   if (retval == 0) {
  1041   if (retval == 0) {
  1204 
  1194 
  1205   ::exit(1);
  1195   ::exit(1);
  1206 }
  1196 }
  1207 
  1197 
  1208 // Die immediately, no exit hook, no abort hook, no cleanup.
  1198 // Die immediately, no exit hook, no abort hook, no cleanup.
       
  1199 // Dump a core file, if possible, for debugging.
  1209 void os::die() {
  1200 void os::die() {
  1210   ::abort();
  1201   if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
       
  1202     // For TimeoutInErrorHandlingTest.java, we just kill the VM
       
  1203     // and don't take the time to generate a core file.
       
  1204     os::signal_raise(SIGKILL);
       
  1205   } else {
       
  1206     ::abort();
       
  1207   }
  1211 }
  1208 }
  1212 
  1209 
  1213 intx os::current_thread_id() {
  1210 intx os::current_thread_id() {
  1214   return (intx)pthread_self();
  1211   return (intx)pthread_self();
  1215 }
  1212 }
  1305 
  1302 
  1306 // Loads .dll/.so and in case of error it checks if .dll/.so was built
  1303 // Loads .dll/.so and in case of error it checks if .dll/.so was built
  1307 // for the same architecture as Hotspot is running on.
  1304 // for the same architecture as Hotspot is running on.
  1308 void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
  1305 void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
  1309 
  1306 
       
  1307   log_info(os)("attempting shared library load of %s", filename);
       
  1308 
  1310   if (ebuf && ebuflen > 0) {
  1309   if (ebuf && ebuflen > 0) {
  1311     ebuf[0] = '\0';
  1310     ebuf[0] = '\0';
  1312     ebuf[ebuflen - 1] = '\0';
  1311     ebuf[ebuflen - 1] = '\0';
  1313   }
  1312   }
  1314 
  1313 
  1318   }
  1317   }
  1319 
  1318 
  1320   // RTLD_LAZY is currently not implemented. The dl is loaded immediately with all its dependants.
  1319   // RTLD_LAZY is currently not implemented. The dl is loaded immediately with all its dependants.
  1321   void * result= ::dlopen(filename, RTLD_LAZY);
  1320   void * result= ::dlopen(filename, RTLD_LAZY);
  1322   if (result != NULL) {
  1321   if (result != NULL) {
       
  1322     Events::log(NULL, "Loaded shared library %s", filename);
  1323     // Reload dll cache. Don't do this in signal handling.
  1323     // Reload dll cache. Don't do this in signal handling.
  1324     LoadedLibraries::reload();
  1324     LoadedLibraries::reload();
       
  1325     log_info(os)("shared library load of %s was successful", filename);
  1325     return result;
  1326     return result;
  1326   } else {
  1327   } else {
  1327     // error analysis when dlopen fails
  1328     // error analysis when dlopen fails
  1328     const char* const error_report = ::dlerror();
  1329     const char* error_report = ::dlerror();
  1329     if (error_report && ebuf && ebuflen > 0) {
  1330     if (error_report == NULL) {
       
  1331       error_report = "dlerror returned no error description";
       
  1332     }
       
  1333     if (ebuf != NULL && ebuflen > 0) {
  1330       snprintf(ebuf, ebuflen - 1, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s",
  1334       snprintf(ebuf, ebuflen - 1, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s",
  1331                filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
  1335                filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
  1332     }
  1336     }
       
  1337     Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
       
  1338     log_info(os)("shared library load of %s failed, %s", filename, error_report);
  1333   }
  1339   }
  1334   return NULL;
  1340   return NULL;
  1335 }
  1341 }
  1336 
  1342 
  1337 void* os::dll_lookup(void* handle, const char* name) {
  1343 void* os::dll_lookup(void* handle, const char* name) {
  1371 }
  1377 }
  1372 
  1378 
  1373 void os::print_os_info(outputStream* st) {
  1379 void os::print_os_info(outputStream* st) {
  1374   st->print("OS:");
  1380   st->print("OS:");
  1375 
  1381 
  1376   st->print("uname:");
  1382   os::Posix::print_uname_info(st);
  1377   struct utsname name;
       
  1378   uname(&name);
       
  1379   st->print(name.sysname); st->print(" ");
       
  1380   st->print(name.nodename); st->print(" ");
       
  1381   st->print(name.release); st->print(" ");
       
  1382   st->print(name.version); st->print(" ");
       
  1383   st->print(name.machine);
       
  1384   st->cr();
       
  1385 
  1383 
  1386   uint32_t ver = os::Aix::os_version();
  1384   uint32_t ver = os::Aix::os_version();
  1387   st->print_cr("AIX kernel version %u.%u.%u.%u",
  1385   st->print_cr("AIX kernel version %u.%u.%u.%u",
  1388                (ver >> 24) & 0xFF, (ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
  1386                (ver >> 24) & 0xFF, (ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
  1389 
  1387 
  1390   os::Posix::print_rlimit_info(st);
  1388   os::Posix::print_rlimit_info(st);
  1391 
  1389 
       
  1390   os::Posix::print_load_average(st);
       
  1391 
  1392   // _SC_THREAD_THREADS_MAX is the maximum number of threads within a process.
  1392   // _SC_THREAD_THREADS_MAX is the maximum number of threads within a process.
  1393   long tmax = sysconf(_SC_THREAD_THREADS_MAX);
  1393   long tmax = sysconf(_SC_THREAD_THREADS_MAX);
  1394   st->print_cr("maximum #threads within a process:%ld", tmax);
  1394   st->print_cr("maximum #threads within a process:%ld", tmax);
  1395 
       
  1396   // load average
       
  1397   st->print("load average:");
       
  1398   double loadavg[3] = {-1.L, -1.L, -1.L};
       
  1399   os::loadavg(loadavg, 3);
       
  1400   st->print_cr("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
       
  1401 
  1395 
  1402   // print wpar info
  1396   // print wpar info
  1403   libperfstat::wparinfo_t wi;
  1397   libperfstat::wparinfo_t wi;
  1404   if (libperfstat::get_wparinfo(&wi)) {
  1398   if (libperfstat::get_wparinfo(&wi)) {
  1405     st->print_cr("wpar info");
  1399     st->print_cr("wpar info");
  1423     describe_pagesize(g_multipage_support.textpsize));
  1417     describe_pagesize(g_multipage_support.textpsize));
  1424   st->print_cr("  Thread stack page size (pthread):       %s",
  1418   st->print_cr("  Thread stack page size (pthread):       %s",
  1425     describe_pagesize(g_multipage_support.pthr_stack_pagesize));
  1419     describe_pagesize(g_multipage_support.pthr_stack_pagesize));
  1426   st->print_cr("  Default shared memory page size:        %s",
  1420   st->print_cr("  Default shared memory page size:        %s",
  1427     describe_pagesize(g_multipage_support.shmpsize));
  1421     describe_pagesize(g_multipage_support.shmpsize));
  1428   st->print_cr("  Can use 64K pages dynamically with shared meory:  %s",
  1422   st->print_cr("  Can use 64K pages dynamically with shared memory:  %s",
  1429     (g_multipage_support.can_use_64K_pages ? "yes" :"no"));
  1423     (g_multipage_support.can_use_64K_pages ? "yes" :"no"));
  1430   st->print_cr("  Can use 16M pages dynamically with shared memory: %s",
  1424   st->print_cr("  Can use 16M pages dynamically with shared memory: %s",
  1431     (g_multipage_support.can_use_16M_pages ? "yes" :"no"));
  1425     (g_multipage_support.can_use_16M_pages ? "yes" :"no"));
  1432   st->print_cr("  Multipage error: %d",
  1426   st->print_cr("  Multipage error: %d",
  1433     g_multipage_support.error);
  1427     g_multipage_support.error);
  1489 
  1483 
  1490 // Get a string for the cpuinfo that is a summary of the cpu type
  1484 // Get a string for the cpuinfo that is a summary of the cpu type
  1491 void os::get_summary_cpu_info(char* buf, size_t buflen) {
  1485 void os::get_summary_cpu_info(char* buf, size_t buflen) {
  1492   // read _system_configuration.version
  1486   // read _system_configuration.version
  1493   switch (_system_configuration.version) {
  1487   switch (_system_configuration.version) {
       
  1488   case PV_9:
       
  1489     strncpy(buf, "Power PC 9", buflen);
       
  1490     break;
  1494   case PV_8:
  1491   case PV_8:
  1495     strncpy(buf, "Power PC 8", buflen);
  1492     strncpy(buf, "Power PC 8", buflen);
  1496     break;
  1493     break;
  1497   case PV_7:
  1494   case PV_7:
  1498     strncpy(buf, "Power PC 7", buflen);
  1495     strncpy(buf, "Power PC 7", buflen);
  1522     strncpy(buf, "PV_7_Compat", buflen);
  1519     strncpy(buf, "PV_7_Compat", buflen);
  1523     break;
  1520     break;
  1524   case PV_8_Compat:
  1521   case PV_8_Compat:
  1525     strncpy(buf, "PV_8_Compat", buflen);
  1522     strncpy(buf, "PV_8_Compat", buflen);
  1526     break;
  1523     break;
       
  1524   case PV_9_Compat:
       
  1525     strncpy(buf, "PV_9_Compat", buflen);
       
  1526     break;
  1527   default:
  1527   default:
  1528     strncpy(buf, "unknown", buflen);
  1528     strncpy(buf, "unknown", buflen);
  1529   }
  1529   }
  1530 }
  1530 }
  1531 
  1531 
  1648 }
  1648 }
  1649 
  1649 
  1650 ////////////////////////////////////////////////////////////////////////////////
  1650 ////////////////////////////////////////////////////////////////////////////////
  1651 // sun.misc.Signal support
  1651 // sun.misc.Signal support
  1652 
  1652 
  1653 static volatile jint sigint_count = 0;
       
  1654 
       
  1655 static void
  1653 static void
  1656 UserHandler(int sig, void *siginfo, void *context) {
  1654 UserHandler(int sig, void *siginfo, void *context) {
  1657   // 4511530 - sem_post is serialized and handled by the manager thread. When
       
  1658   // the program is interrupted by Ctrl-C, SIGINT is sent to every thread. We
       
  1659   // don't want to flood the manager thread with sem_post requests.
       
  1660   if (sig == SIGINT && Atomic::add(1, &sigint_count) > 1)
       
  1661     return;
       
  1662 
       
  1663   // Ctrl-C is pressed during error reporting, likely because the error
  1655   // Ctrl-C is pressed during error reporting, likely because the error
  1664   // handler fails to abort. Let VM die immediately.
  1656   // handler fails to abort. Let VM die immediately.
  1665   if (sig == SIGINT && VMError::is_error_reported()) {
  1657   if (sig == SIGINT && VMError::is_error_reported()) {
  1666     os::die();
  1658     os::die();
  1667   }
  1659   }
  1797   Atomic::inc(&pending_signals[sig]);
  1789   Atomic::inc(&pending_signals[sig]);
  1798   local_sem_post();
  1790   local_sem_post();
  1799 }
  1791 }
  1800 
  1792 
  1801 static int check_pending_signals() {
  1793 static int check_pending_signals() {
  1802   Atomic::store(0, &sigint_count);
       
  1803   for (;;) {
  1794   for (;;) {
  1804     for (int i = 0; i < NSIG + 1; i++) {
  1795     for (int i = 0; i < NSIG + 1; i++) {
  1805       jint n = pending_signals[i];
  1796       jint n = pending_signals[i];
  1806       if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
  1797       if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
  1807         return i;
  1798         return i;
  1874   // also check that range is fully page aligned to the page size if the block.
  1865   // also check that range is fully page aligned to the page size if the block.
  1875   void assert_is_valid_subrange(char* p, size_t s) const {
  1866   void assert_is_valid_subrange(char* p, size_t s) const {
  1876     if (!contains_range(p, s)) {
  1867     if (!contains_range(p, s)) {
  1877       trcVerbose("[" PTR_FORMAT " - " PTR_FORMAT "] is not a sub "
  1868       trcVerbose("[" PTR_FORMAT " - " PTR_FORMAT "] is not a sub "
  1878               "range of [" PTR_FORMAT " - " PTR_FORMAT "].",
  1869               "range of [" PTR_FORMAT " - " PTR_FORMAT "].",
  1879               p, p + s, addr, addr + size);
  1870               p2i(p), p2i(p + s), p2i(addr), p2i(addr + size));
  1880       guarantee0(false);
  1871       guarantee0(false);
  1881     }
  1872     }
  1882     if (!is_aligned_to(p, pagesize) || !is_aligned_to(p + s, pagesize)) {
  1873     if (!is_aligned_to(p, pagesize) || !is_aligned_to(p + s, pagesize)) {
  1883       trcVerbose("range [" PTR_FORMAT " - " PTR_FORMAT "] is not"
  1874       trcVerbose("range [" PTR_FORMAT " - " PTR_FORMAT "] is not"
  1884               " aligned to pagesize (%lu)", p, p + s, (unsigned long) pagesize);
  1875               " aligned to pagesize (%lu)", p2i(p), p2i(p + s), (unsigned long) pagesize);
  1885       guarantee0(false);
  1876       guarantee0(false);
  1886     }
  1877     }
  1887   }
  1878   }
  1888 };
  1879 };
  1889 
  1880 
  1950   char* requested_addr,
  1941   char* requested_addr,
  1951   size_t alignment_hint) {
  1942   size_t alignment_hint) {
  1952 
  1943 
  1953   trcVerbose("reserve_shmated_memory " UINTX_FORMAT " bytes, wishaddress "
  1944   trcVerbose("reserve_shmated_memory " UINTX_FORMAT " bytes, wishaddress "
  1954     PTR_FORMAT ", alignment_hint " UINTX_FORMAT "...",
  1945     PTR_FORMAT ", alignment_hint " UINTX_FORMAT "...",
  1955     bytes, requested_addr, alignment_hint);
  1946     bytes, p2i(requested_addr), alignment_hint);
  1956 
  1947 
  1957   // Either give me wish address or wish alignment but not both.
  1948   // Either give me wish address or wish alignment but not both.
  1958   assert0(!(requested_addr != NULL && alignment_hint != 0));
  1949   assert0(!(requested_addr != NULL && alignment_hint != 0));
  1959 
  1950 
  1960   // We must prevent anyone from attaching too close to the
  1951   // We must prevent anyone from attaching too close to the
  1961   // BRK because that may cause malloc OOM.
  1952   // BRK because that may cause malloc OOM.
  1962   if (requested_addr != NULL && is_close_to_brk((address)requested_addr)) {
  1953   if (requested_addr != NULL && is_close_to_brk((address)requested_addr)) {
  1963     trcVerbose("Wish address " PTR_FORMAT " is too close to the BRK segment. "
  1954     trcVerbose("Wish address " PTR_FORMAT " is too close to the BRK segment. "
  1964       "Will attach anywhere.", requested_addr);
  1955       "Will attach anywhere.", p2i(requested_addr));
  1965     // Act like the OS refused to attach there.
  1956     // Act like the OS refused to attach there.
  1966     requested_addr = NULL;
  1957     requested_addr = NULL;
  1967   }
  1958   }
  1968 
  1959 
  1969   // For old AS/400's (V5R4 and older) we should not even be here - System V shared memory is not
  1960   // For old AS/400's (V5R4 and older) we should not even be here - System V shared memory is not
  2011     assert(false, "failed to remove shared memory segment!");
  2002     assert(false, "failed to remove shared memory segment!");
  2012   }
  2003   }
  2013 
  2004 
  2014   // Handle shmat error. If we failed to attach, just return.
  2005   // Handle shmat error. If we failed to attach, just return.
  2015   if (addr == (char*)-1) {
  2006   if (addr == (char*)-1) {
  2016     trcVerbose("Failed to attach segment at " PTR_FORMAT " (%d).", requested_addr, errno_shmat);
  2007     trcVerbose("Failed to attach segment at " PTR_FORMAT " (%d).", p2i(requested_addr), errno_shmat);
  2017     return NULL;
  2008     return NULL;
  2018   }
  2009   }
  2019 
  2010 
  2020   // Just for info: query the real page size. In case setting the page size did not
  2011   // Just for info: query the real page size. In case setting the page size did not
  2021   // work (see above), the system may have given us something other then 4K (LDR_CNTRL).
  2012   // work (see above), the system may have given us something other then 4K (LDR_CNTRL).
  2022   const size_t real_pagesize = os::Aix::query_pagesize(addr);
  2013   const size_t real_pagesize = os::Aix::query_pagesize(addr);
  2023   if (real_pagesize != shmbuf.shm_pagesize) {
  2014   if (real_pagesize != shmbuf.shm_pagesize) {
  2024     trcVerbose("pagesize is, surprisingly, %h.", real_pagesize);
  2015     trcVerbose("pagesize is, surprisingly, " SIZE_FORMAT, real_pagesize);
  2025   }
  2016   }
  2026 
  2017 
  2027   if (addr) {
  2018   if (addr) {
  2028     trcVerbose("shm-allocated " PTR_FORMAT " .. " PTR_FORMAT " (" UINTX_FORMAT " bytes, " UINTX_FORMAT " %s pages)",
  2019     trcVerbose("shm-allocated " PTR_FORMAT " .. " PTR_FORMAT " (" UINTX_FORMAT " bytes, " UINTX_FORMAT " %s pages)",
  2029       addr, addr + size - 1, size, size/real_pagesize, describe_pagesize(real_pagesize));
  2020       p2i(addr), p2i(addr + size - 1), size, size/real_pagesize, describe_pagesize(real_pagesize));
  2030   } else {
  2021   } else {
  2031     if (requested_addr != NULL) {
  2022     if (requested_addr != NULL) {
  2032       trcVerbose("failed to shm-allocate " UINTX_FORMAT " bytes at with address " PTR_FORMAT ".", size, requested_addr);
  2023       trcVerbose("failed to shm-allocate " UINTX_FORMAT " bytes at with address " PTR_FORMAT ".", size, p2i(requested_addr));
  2033     } else {
  2024     } else {
  2034       trcVerbose("failed to shm-allocate " UINTX_FORMAT " bytes at any address.", size);
  2025       trcVerbose("failed to shm-allocate " UINTX_FORMAT " bytes at any address.", size);
  2035     }
  2026     }
  2036   }
  2027   }
  2037 
  2028 
  2043 }
  2034 }
  2044 
  2035 
  2045 static bool release_shmated_memory(char* addr, size_t size) {
  2036 static bool release_shmated_memory(char* addr, size_t size) {
  2046 
  2037 
  2047   trcVerbose("release_shmated_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2038   trcVerbose("release_shmated_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2048     addr, addr + size - 1);
  2039     p2i(addr), p2i(addr + size - 1));
  2049 
  2040 
  2050   bool rc = false;
  2041   bool rc = false;
  2051 
  2042 
  2052   // TODO: is there a way to verify shm size without doing bookkeeping?
  2043   // TODO: is there a way to verify shm size without doing bookkeeping?
  2053   if (::shmdt(addr) != 0) {
  2044   if (::shmdt(addr) != 0) {
  2059   return rc;
  2050   return rc;
  2060 }
  2051 }
  2061 
  2052 
  2062 static bool uncommit_shmated_memory(char* addr, size_t size) {
  2053 static bool uncommit_shmated_memory(char* addr, size_t size) {
  2063   trcVerbose("uncommit_shmated_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2054   trcVerbose("uncommit_shmated_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2064     addr, addr + size - 1);
  2055     p2i(addr), p2i(addr + size - 1));
  2065 
  2056 
  2066   const bool rc = my_disclaim64(addr, size);
  2057   const bool rc = my_disclaim64(addr, size);
  2067 
  2058 
  2068   if (!rc) {
  2059   if (!rc) {
  2069     trcVerbose("my_disclaim64(" PTR_FORMAT ", " UINTX_FORMAT ") failed.\n", addr, size);
  2060     trcVerbose("my_disclaim64(" PTR_FORMAT ", " UINTX_FORMAT ") failed.\n", p2i(addr), size);
  2070     return false;
  2061     return false;
  2071   }
  2062   }
  2072   return true;
  2063   return true;
  2073 }
  2064 }
  2074 
  2065 
  2081 // allocate at an address aligned with the given alignment. Failing that, memory
  2072 // allocate at an address aligned with the given alignment. Failing that, memory
  2082 // is aligned anywhere.
  2073 // is aligned anywhere.
  2083 static char* reserve_mmaped_memory(size_t bytes, char* requested_addr, size_t alignment_hint) {
  2074 static char* reserve_mmaped_memory(size_t bytes, char* requested_addr, size_t alignment_hint) {
  2084   trcVerbose("reserve_mmaped_memory " UINTX_FORMAT " bytes, wishaddress " PTR_FORMAT ", "
  2075   trcVerbose("reserve_mmaped_memory " UINTX_FORMAT " bytes, wishaddress " PTR_FORMAT ", "
  2085     "alignment_hint " UINTX_FORMAT "...",
  2076     "alignment_hint " UINTX_FORMAT "...",
  2086     bytes, requested_addr, alignment_hint);
  2077     bytes, p2i(requested_addr), alignment_hint);
  2087 
  2078 
  2088   // If a wish address is given, but not aligned to 4K page boundary, mmap will fail.
  2079   // If a wish address is given, but not aligned to 4K page boundary, mmap will fail.
  2089   if (requested_addr && !is_aligned_to(requested_addr, os::vm_page_size()) != 0) {
  2080   if (requested_addr && !is_aligned_to(requested_addr, os::vm_page_size()) != 0) {
  2090     trcVerbose("Wish address " PTR_FORMAT " not aligned to page boundary.", requested_addr);
  2081     trcVerbose("Wish address " PTR_FORMAT " not aligned to page boundary.", p2i(requested_addr));
  2091     return NULL;
  2082     return NULL;
  2092   }
  2083   }
  2093 
  2084 
  2094   // We must prevent anyone from attaching too close to the
  2085   // We must prevent anyone from attaching too close to the
  2095   // BRK because that may cause malloc OOM.
  2086   // BRK because that may cause malloc OOM.
  2096   if (requested_addr != NULL && is_close_to_brk((address)requested_addr)) {
  2087   if (requested_addr != NULL && is_close_to_brk((address)requested_addr)) {
  2097     trcVerbose("Wish address " PTR_FORMAT " is too close to the BRK segment. "
  2088     trcVerbose("Wish address " PTR_FORMAT " is too close to the BRK segment. "
  2098       "Will attach anywhere.", requested_addr);
  2089       "Will attach anywhere.", p2i(requested_addr));
  2099     // Act like the OS refused to attach there.
  2090     // Act like the OS refused to attach there.
  2100     requested_addr = NULL;
  2091     requested_addr = NULL;
  2101   }
  2092   }
  2102 
  2093 
  2103   // Specify one or the other but not both.
  2094   // Specify one or the other but not both.
  2140 
  2131 
  2141   char* addr = (char*)::mmap(requested_addr, extra_size,
  2132   char* addr = (char*)::mmap(requested_addr, extra_size,
  2142       PROT_READ|PROT_WRITE|PROT_EXEC, flags, -1, 0);
  2133       PROT_READ|PROT_WRITE|PROT_EXEC, flags, -1, 0);
  2143 
  2134 
  2144   if (addr == MAP_FAILED) {
  2135   if (addr == MAP_FAILED) {
  2145     trcVerbose("mmap(" PTR_FORMAT ", " UINTX_FORMAT ", ..) failed (%d)", requested_addr, size, errno);
  2136     trcVerbose("mmap(" PTR_FORMAT ", " UINTX_FORMAT ", ..) failed (%d)", p2i(requested_addr), size, errno);
  2146     return NULL;
  2137     return NULL;
  2147   }
  2138   }
  2148 
  2139 
  2149   // Handle alignment.
  2140   // Handle alignment.
  2150   char* const addr_aligned = align_up(addr, alignment_hint);
  2141   char* const addr_aligned = align_up(addr, alignment_hint);
  2159   }
  2150   }
  2160   addr = addr_aligned;
  2151   addr = addr_aligned;
  2161 
  2152 
  2162   if (addr) {
  2153   if (addr) {
  2163     trcVerbose("mmap-allocated " PTR_FORMAT " .. " PTR_FORMAT " (" UINTX_FORMAT " bytes)",
  2154     trcVerbose("mmap-allocated " PTR_FORMAT " .. " PTR_FORMAT " (" UINTX_FORMAT " bytes)",
  2164       addr, addr + bytes, bytes);
  2155       p2i(addr), p2i(addr + bytes), bytes);
  2165   } else {
  2156   } else {
  2166     if (requested_addr != NULL) {
  2157     if (requested_addr != NULL) {
  2167       trcVerbose("failed to mmap-allocate " UINTX_FORMAT " bytes at wish address " PTR_FORMAT ".", bytes, requested_addr);
  2158       trcVerbose("failed to mmap-allocate " UINTX_FORMAT " bytes at wish address " PTR_FORMAT ".", bytes, p2i(requested_addr));
  2168     } else {
  2159     } else {
  2169       trcVerbose("failed to mmap-allocate " UINTX_FORMAT " bytes at any address.", bytes);
  2160       trcVerbose("failed to mmap-allocate " UINTX_FORMAT " bytes at any address.", bytes);
  2170     }
  2161     }
  2171   }
  2162   }
  2172 
  2163 
  2182 static bool release_mmaped_memory(char* addr, size_t size) {
  2173 static bool release_mmaped_memory(char* addr, size_t size) {
  2183   assert0(is_aligned_to(addr, os::vm_page_size()));
  2174   assert0(is_aligned_to(addr, os::vm_page_size()));
  2184   assert0(is_aligned_to(size, os::vm_page_size()));
  2175   assert0(is_aligned_to(size, os::vm_page_size()));
  2185 
  2176 
  2186   trcVerbose("release_mmaped_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2177   trcVerbose("release_mmaped_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2187     addr, addr + size - 1);
  2178     p2i(addr), p2i(addr + size - 1));
  2188   bool rc = false;
  2179   bool rc = false;
  2189 
  2180 
  2190   if (::munmap(addr, size) != 0) {
  2181   if (::munmap(addr, size) != 0) {
  2191     trcVerbose("failed (%d)\n", errno);
  2182     trcVerbose("failed (%d)\n", errno);
  2192     rc = false;
  2183     rc = false;
  2202 
  2193 
  2203   assert0(is_aligned_to(addr, os::vm_page_size()));
  2194   assert0(is_aligned_to(addr, os::vm_page_size()));
  2204   assert0(is_aligned_to(size, os::vm_page_size()));
  2195   assert0(is_aligned_to(size, os::vm_page_size()));
  2205 
  2196 
  2206   trcVerbose("uncommit_mmaped_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2197   trcVerbose("uncommit_mmaped_memory [" PTR_FORMAT " - " PTR_FORMAT "].",
  2207     addr, addr + size - 1);
  2198     p2i(addr), p2i(addr + size - 1));
  2208   bool rc = false;
  2199   bool rc = false;
  2209 
  2200 
  2210   // Uncommit mmap memory with msync MS_INVALIDATE.
  2201   // Uncommit mmap memory with msync MS_INVALIDATE.
  2211   if (::msync(addr, size, MS_INVALIDATE) != 0) {
  2202   if (::msync(addr, size, MS_INVALIDATE) != 0) {
  2212     trcVerbose("failed (%d)\n", errno);
  2203     trcVerbose("failed (%d)\n", errno);
  2233 
  2224 
  2234 #ifdef PRODUCT
  2225 #ifdef PRODUCT
  2235 static void warn_fail_commit_memory(char* addr, size_t size, bool exec,
  2226 static void warn_fail_commit_memory(char* addr, size_t size, bool exec,
  2236                                     int err) {
  2227                                     int err) {
  2237   warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT
  2228   warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT
  2238           ", %d) failed; error='%s' (errno=%d)", addr, size, exec,
  2229           ", %d) failed; error='%s' (errno=%d)", p2i(addr), size, exec,
  2239           os::errno_name(err), err);
  2230           os::errno_name(err), err);
  2240 }
  2231 }
  2241 #endif
  2232 #endif
  2242 
  2233 
  2243 void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec,
  2234 void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec,
  2261 
  2252 
  2262   vmembk_t* const vmi = vmembk_find(addr);
  2253   vmembk_t* const vmi = vmembk_find(addr);
  2263   guarantee0(vmi);
  2254   guarantee0(vmi);
  2264   vmi->assert_is_valid_subrange(addr, size);
  2255   vmi->assert_is_valid_subrange(addr, size);
  2265 
  2256 
  2266   trcVerbose("commit_memory [" PTR_FORMAT " - " PTR_FORMAT "].", addr, addr + size - 1);
  2257   trcVerbose("commit_memory [" PTR_FORMAT " - " PTR_FORMAT "].", p2i(addr), p2i(addr + size - 1));
  2267 
  2258 
  2268   if (UseExplicitCommit) {
  2259   if (UseExplicitCommit) {
  2269     // AIX commits memory on touch. So, touch all pages to be committed.
  2260     // AIX commits memory on touch. So, touch all pages to be committed.
  2270     for (char* p = addr; p < (addr + size); p += 4*K) {
  2261     for (char* p = addr; p < (addr + size); p += 4*K) {
  2271       *p = '\0';
  2262       *p = '\0';
  2648   60,             // 10 MaxPriority
  2639   60,             // 10 MaxPriority
  2649 
  2640 
  2650   60              // 11 CriticalPriority
  2641   60              // 11 CriticalPriority
  2651 };
  2642 };
  2652 
  2643 
       
  2644 static int prio_init() {
       
  2645   if (ThreadPriorityPolicy == 1) {
       
  2646     if (geteuid() != 0) {
       
  2647       if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
       
  2648         warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \
       
  2649                 "e.g., being the root user. If the necessary permission is not " \
       
  2650                 "possessed, changes to priority will be silently ignored.");
       
  2651       }
       
  2652     }
       
  2653   }
       
  2654   if (UseCriticalJavaThreadPriority) {
       
  2655     os::java_to_os_priority[MaxPriority] = os::java_to_os_priority[CriticalPriority];
       
  2656   }
       
  2657   return 0;
       
  2658 }
       
  2659 
  2653 OSReturn os::set_native_priority(Thread* thread, int newpri) {
  2660 OSReturn os::set_native_priority(Thread* thread, int newpri) {
  2654   if (!UseThreadPriorities) return OS_OK;
  2661   if (!UseThreadPriorities || ThreadPriorityPolicy == 0) return OS_OK;
  2655   pthread_t thr = thread->osthread()->pthread_id();
  2662   pthread_t thr = thread->osthread()->pthread_id();
  2656   int policy = SCHED_OTHER;
  2663   int policy = SCHED_OTHER;
  2657   struct sched_param param;
  2664   struct sched_param param;
  2658   param.sched_priority = newpri;
  2665   param.sched_priority = newpri;
  2659   int ret = pthread_setschedparam(thr, policy, &param);
  2666   int ret = pthread_setschedparam(thr, policy, &param);
  2664   }
  2671   }
  2665   return (ret == 0) ? OS_OK : OS_ERR;
  2672   return (ret == 0) ? OS_OK : OS_ERR;
  2666 }
  2673 }
  2667 
  2674 
  2668 OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
  2675 OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
  2669   if (!UseThreadPriorities) {
  2676   if (!UseThreadPriorities || ThreadPriorityPolicy == 0) {
  2670     *priority_ptr = java_to_os_priority[NormPriority];
  2677     *priority_ptr = java_to_os_priority[NormPriority];
  2671     return OS_OK;
  2678     return OS_OK;
  2672   }
  2679   }
  2673   pthread_t thr = thread->osthread()->pthread_id();
  2680   pthread_t thr = thread->osthread()->pthread_id();
  2674   int policy = SCHED_OTHER;
  2681   int policy = SCHED_OTHER;
  2761 
  2768 
  2762     // attempt to switch the state, we assume we had a SUSPEND_REQUEST
  2769     // attempt to switch the state, we assume we had a SUSPEND_REQUEST
  2763     os::SuspendResume::State state = osthread->sr.suspended();
  2770     os::SuspendResume::State state = osthread->sr.suspended();
  2764     if (state == os::SuspendResume::SR_SUSPENDED) {
  2771     if (state == os::SuspendResume::SR_SUSPENDED) {
  2765       sigset_t suspend_set;  // signals for sigsuspend()
  2772       sigset_t suspend_set;  // signals for sigsuspend()
  2766 
  2773       sigemptyset(&suspend_set);
  2767       // get current set of blocked signals and unblock resume signal
  2774       // get current set of blocked signals and unblock resume signal
  2768       pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
  2775       pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
  2769       sigdelset(&suspend_set, SR_signum);
  2776       sigdelset(&suspend_set, SR_signum);
  2770 
  2777 
  2771       // wait here until we are resumed
  2778       // wait here until we are resumed
  3047       actp->sa_handler = SIG_DFL;
  3054       actp->sa_handler = SIG_DFL;
  3048     }
  3055     }
  3049 
  3056 
  3050     // try to honor the signal mask
  3057     // try to honor the signal mask
  3051     sigset_t oset;
  3058     sigset_t oset;
       
  3059     sigemptyset(&oset);
  3052     pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
  3060     pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
  3053 
  3061 
  3054     // call into the chained handler
  3062     // call into the chained handler
  3055     if (siginfo_flag_set) {
  3063     if (siginfo_flag_set) {
  3056       (*sa)(sig, siginfo, context);
  3064       (*sa)(sig, siginfo, context);
  3057     } else {
  3065     } else {
  3058       (*hand)(sig);
  3066       (*hand)(sig);
  3059     }
  3067     }
  3060 
  3068 
  3061     // restore the signal mask
  3069     // restore the signal mask
  3062     pthread_sigmask(SIG_SETMASK, &oset, 0);
  3070     pthread_sigmask(SIG_SETMASK, &oset, NULL);
  3063   }
  3071   }
  3064   // Tell jvm's signal handler the signal is taken care of.
  3072   // Tell jvm's signal handler the signal is taken care of.
  3065   return true;
  3073   return true;
  3066 }
  3074 }
  3067 
  3075 
  3490   init_random(1234567);
  3498   init_random(1234567);
  3491 
  3499 
  3492   // _main_thread points to the thread that created/loaded the JVM.
  3500   // _main_thread points to the thread that created/loaded the JVM.
  3493   Aix::_main_thread = pthread_self();
  3501   Aix::_main_thread = pthread_self();
  3494 
  3502 
  3495   initial_time_count = os::elapsed_counter();
  3503   initial_time_count = javaTimeNanos();
  3496 
  3504 
  3497   os::Posix::init();
  3505   os::Posix::init();
  3498 }
  3506 }
  3499 
  3507 
  3500 // This is called _after_ the global arguments have been parsed.
  3508 // This is called _after_ the global arguments have been parsed.
  3573     if (atexit(perfMemory_exit_helper) != 0) {
  3581     if (atexit(perfMemory_exit_helper) != 0) {
  3574       warning("os::init_2 atexit(perfMemory_exit_helper) failed");
  3582       warning("os::init_2 atexit(perfMemory_exit_helper) failed");
  3575     }
  3583     }
  3576   }
  3584   }
  3577 
  3585 
       
  3586   // initialize thread priority policy
       
  3587   prio_init();
       
  3588 
  3578   return JNI_OK;
  3589   return JNI_OK;
  3579 }
  3590 }
  3580 
  3591 
  3581 // Mark the polling page as unreadable
  3592 // Mark the polling page as unreadable
  3582 void os::make_polling_page_unreadable(void) {
  3593 void os::make_polling_page_unreadable(void) {
  3608 }
  3619 }
  3609 
  3620 
  3610 void os::set_native_thread_name(const char *name) {
  3621 void os::set_native_thread_name(const char *name) {
  3611   // Not yet implemented.
  3622   // Not yet implemented.
  3612   return;
  3623   return;
  3613 }
       
  3614 
       
  3615 bool os::distribute_processes(uint length, uint* distribution) {
       
  3616   // Not yet implemented.
       
  3617   return false;
       
  3618 }
  3624 }
  3619 
  3625 
  3620 bool os::bind_to_processor(uint processor_id) {
  3626 bool os::bind_to_processor(uint processor_id) {
  3621   // Not yet implemented.
  3627   // Not yet implemented.
  3622   return false;
  3628   return false;
  4014 }
  4020 }
  4015 
  4021 
  4016 void os::pause() {
  4022 void os::pause() {
  4017   char filename[MAX_PATH];
  4023   char filename[MAX_PATH];
  4018   if (PauseAtStartupFile && PauseAtStartupFile[0]) {
  4024   if (PauseAtStartupFile && PauseAtStartupFile[0]) {
  4019     jio_snprintf(filename, MAX_PATH, PauseAtStartupFile);
  4025     jio_snprintf(filename, MAX_PATH, "%s", PauseAtStartupFile);
  4020   } else {
  4026   } else {
  4021     jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
  4027     jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
  4022   }
  4028   }
  4023 
  4029 
  4024   int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
  4030   int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
  4061     assert(major > 0, "invalid OS version");
  4067     assert(major > 0, "invalid OS version");
  4062     const int minor = atoi(uts.release);
  4068     const int minor = atoi(uts.release);
  4063     assert(minor > 0, "invalid OS release");
  4069     assert(minor > 0, "invalid OS release");
  4064     _os_version = (major << 24) | (minor << 16);
  4070     _os_version = (major << 24) | (minor << 16);
  4065     char ver_str[20] = {0};
  4071     char ver_str[20] = {0};
  4066     char *name_str = "unknown OS";
  4072     const char* name_str = "unknown OS";
  4067     if (strcmp(uts.sysname, "OS400") == 0) {
  4073     if (strcmp(uts.sysname, "OS400") == 0) {
  4068       // We run on AS/400 PASE. We do not support versions older than V5R4M0.
  4074       // We run on AS/400 PASE. We do not support versions older than V5R4M0.
  4069       _on_pase = 1;
  4075       _on_pase = 1;
  4070       if (os_version_short() < 0x0504) {
  4076       if (os_version_short() < 0x0504) {
  4071         trcVerbose("OS/400 releases older than V5R4M0 not supported.");
  4077         trcVerbose("OS/400 releases older than V5R4M0 not supported.");
  4072         assert(false, "OS/400 release too old.");
  4078         assert(false, "OS/400 release too old.");
  4073       }
  4079       }
  4074       name_str = "OS/400 (pase)";
  4080       name_str = "OS/400 (pase)";
  4075       jio_snprintf(ver_str, sizeof(ver_str), "%u.%u", major, minor);
  4081       jio_snprintf(ver_str, sizeof(ver_str), "%u.%u", major, minor);
  4076     } else if (strcmp(uts.sysname, "AIX") == 0) {
  4082     } else if (strcmp(uts.sysname, "AIX") == 0) {
  4077       // We run on AIX. We do not support versions older than AIX 5.3.
  4083       // We run on AIX. We do not support versions older than AIX 7.1.
  4078       _on_pase = 0;
  4084       _on_pase = 0;
  4079       // Determine detailed AIX version: Version, Release, Modification, Fix Level.
  4085       // Determine detailed AIX version: Version, Release, Modification, Fix Level.
  4080       odmWrapper::determine_os_kernel_version(&_os_version);
  4086       odmWrapper::determine_os_kernel_version(&_os_version);
  4081       if (os_version_short() < 0x0503) {
  4087       if (os_version_short() < 0x0701) {
  4082         trcVerbose("AIX release older than AIX 5.3 not supported.");
  4088         trcVerbose("AIX releases older than AIX 7.1 are not supported.");
  4083         assert(false, "AIX release too old.");
  4089         assert(false, "AIX release too old.");
  4084       }
  4090       }
  4085       name_str = "AIX";
  4091       name_str = "AIX";
  4086       jio_snprintf(ver_str, sizeof(ver_str), "%u.%u.%u.%u",
  4092       jio_snprintf(ver_str, sizeof(ver_str), "%u.%u.%u.%u",
  4087                    major, minor, (_os_version >> 8) & 0xFF, _os_version & 0xFF);
  4093                    major, minor, (_os_version >> 8) & 0xFF, _os_version & 0xFF);
  4088     } else {
  4094     } else {
  4089       assert(false, name_str);
  4095       assert(false, "%s", name_str);
  4090     }
  4096     }
  4091     trcVerbose("We run on %s %s", name_str, ver_str);
  4097     trcVerbose("We run on %s %s", name_str, ver_str);
  4092   }
  4098   }
  4093 
  4099 
  4094   guarantee(_on_pase != -1 && _os_version, "Could not determine AIX/OS400 release");
  4100   guarantee(_on_pase != -1 && _os_version, "Could not determine AIX/OS400 release");
  4220 // Run the specified command in a separate process. Return its exit value,
  4226 // Run the specified command in a separate process. Return its exit value,
  4221 // or -1 on failure (e.g. can't fork a new process).
  4227 // or -1 on failure (e.g. can't fork a new process).
  4222 // Unlike system(), this function can be called from signal handler. It
  4228 // Unlike system(), this function can be called from signal handler. It
  4223 // doesn't block SIGINT et al.
  4229 // doesn't block SIGINT et al.
  4224 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
  4230 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
  4225   char * argv[4] = {"sh", "-c", cmd, NULL};
  4231   char* argv[4] = { (char*)"sh", (char*)"-c", cmd, NULL};
  4226 
  4232 
  4227   pid_t pid = fork();
  4233   pid_t pid = fork();
  4228 
  4234 
  4229   if (pid < 0) {
  4235   if (pid < 0) {
  4230     // fork failed
  4236     // fork failed
  4330 int os::compare_file_modified_times(const char* file1, const char* file2) {
  4336 int os::compare_file_modified_times(const char* file1, const char* file2) {
  4331   time_t t1 = get_mtime(file1);
  4337   time_t t1 = get_mtime(file1);
  4332   time_t t2 = get_mtime(file2);
  4338   time_t t2 = get_mtime(file2);
  4333   return t1 - t2;
  4339   return t1 - t2;
  4334 }
  4340 }
       
  4341 
       
  4342 bool os::supports_map_sync() {
       
  4343   return false;
       
  4344 }