< prev index next >

src/hotspot/os/linux/os_linux.cpp

Print this page
rev 56578 : 8232211: Remove dead code from os.hpp|cpp
Reviewed-by: TBD


1347 #ifndef SUPPORTS_CLOCK_MONOTONIC
1348 #error "Build platform doesn't support clock_gettime and related functionality"
1349 #endif
1350 
1351 // Time since start-up in seconds to a fine granularity.
1352 // Used by VMSelfDestructTimer and the MemProfiler.
1353 double os::elapsedTime() {
1354 
1355   return ((double)os::elapsed_counter()) / os::elapsed_frequency(); // nanosecond resolution
1356 }
1357 
1358 jlong os::elapsed_counter() {
1359   return javaTimeNanos() - initial_time_count;
1360 }
1361 
1362 jlong os::elapsed_frequency() {
1363   return NANOSECS_PER_SEC; // nanosecond resolution
1364 }
1365 
1366 bool os::supports_vtime() { return true; }
1367 bool os::enable_vtime()   { return false; }
1368 bool os::vtime_enabled()  { return false; }
1369 
1370 double os::elapsedVTime() {
1371   struct rusage usage;
1372   int retval = getrusage(RUSAGE_THREAD, &usage);
1373   if (retval == 0) {
1374     return (double) (usage.ru_utime.tv_sec + usage.ru_stime.tv_sec) + (double) (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000 * 1000);
1375   } else {
1376     // better than nothing, but not much
1377     return elapsedTime();
1378   }
1379 }
1380 
1381 jlong os::javaTimeMillis() {
1382   timeval time;
1383   int status = gettimeofday(&time, NULL);
1384   assert(status != -1, "linux error");
1385   return jlong(time.tv_sec) * 1000  +  jlong(time.tv_usec / 1000);
1386 }
1387 
1388 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {


4843 
4844     rc = sscanf(_uname.release,"%d.%d.%d", &major, &minor, &fix);
4845     if (rc == 3) {
4846 
4847       if (major < 256 && minor < 256 && fix < 256) {
4848         // Kernel version format is as expected,
4849         // set it overriding unknown state.
4850         _os_version = (major << 16) |
4851                       (minor << 8 ) |
4852                       (fix   << 0 ) ;
4853       }
4854     }
4855   }
4856 }
4857 
4858 uint32_t os::Linux::os_version() {
4859   assert(_os_version != 0, "not initialized");
4860   return _os_version & 0x00FFFFFF;
4861 }
4862 
4863 bool os::Linux::os_version_is_known() {
4864   assert(_os_version != 0, "not initialized");
4865   return _os_version & 0x01000000 ? false : true;
4866 }
4867 
4868 /////
4869 // glibc on Linux platform uses non-documented flag
4870 // to indicate, that some special sort of signal
4871 // trampoline is used.
4872 // We will never set this flag, and we should
4873 // ignore this flag in our diagnostic
4874 #ifdef SIGNIFICANT_SIGNAL_MASK
4875   #undef SIGNIFICANT_SIGNAL_MASK
4876 #endif
4877 #define SIGNIFICANT_SIGNAL_MASK (~0x04000000)
4878 
4879 static const char* get_signal_handler_name(address handler,
4880                                            char* buf, int buflen) {
4881   int offset = 0;
4882   bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
4883   if (found) {
4884     // skip directory names
4885     const char *p1, *p2;
4886     p1 = buf;
4887     size_t len = strlen(os::file_separator());


5446   }
5447 
5448   return active_cpus;
5449 }
5450 
5451 uint os::processor_id() {
5452   const int id = Linux::sched_getcpu();
5453   assert(id >= 0 && id < _processor_count, "Invalid processor id");
5454   return (uint)id;
5455 }
5456 
5457 void os::set_native_thread_name(const char *name) {
5458   if (Linux::_pthread_setname_np) {
5459     char buf [16]; // according to glibc manpage, 16 chars incl. '/0'
5460     snprintf(buf, sizeof(buf), "%s", name);
5461     buf[sizeof(buf) - 1] = '\0';
5462     const int rc = Linux::_pthread_setname_np(pthread_self(), buf);
5463     // ERANGE should not happen; all other errors should just be ignored.
5464     assert(rc != ERANGE, "pthread_setname_np failed");
5465   }
5466 }
5467 
5468 bool os::distribute_processes(uint length, uint* distribution) {
5469   // Not yet implemented.
5470   return false;
5471 }
5472 
5473 bool os::bind_to_processor(uint processor_id) {
5474   // Not yet implemented.
5475   return false;
5476 }
5477 
5478 ///
5479 
5480 void os::SuspendedThreadTask::internal_do_task() {
5481   if (do_suspend(_thread->osthread())) {
5482     SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
5483     do_task(context);
5484     do_resume(_thread->osthread());
5485   }
5486 }
5487 
5488 ////////////////////////////////////////////////////////////////////////////////
5489 // debug support
5490 




1347 #ifndef SUPPORTS_CLOCK_MONOTONIC
1348 #error "Build platform doesn't support clock_gettime and related functionality"
1349 #endif
1350 
1351 // Time since start-up in seconds to a fine granularity.
1352 // Used by VMSelfDestructTimer and the MemProfiler.
1353 double os::elapsedTime() {
1354 
1355   return ((double)os::elapsed_counter()) / os::elapsed_frequency(); // nanosecond resolution
1356 }
1357 
1358 jlong os::elapsed_counter() {
1359   return javaTimeNanos() - initial_time_count;
1360 }
1361 
1362 jlong os::elapsed_frequency() {
1363   return NANOSECS_PER_SEC; // nanosecond resolution
1364 }
1365 
1366 bool os::supports_vtime() { return true; }


1367 
1368 double os::elapsedVTime() {
1369   struct rusage usage;
1370   int retval = getrusage(RUSAGE_THREAD, &usage);
1371   if (retval == 0) {
1372     return (double) (usage.ru_utime.tv_sec + usage.ru_stime.tv_sec) + (double) (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000 * 1000);
1373   } else {
1374     // better than nothing, but not much
1375     return elapsedTime();
1376   }
1377 }
1378 
1379 jlong os::javaTimeMillis() {
1380   timeval time;
1381   int status = gettimeofday(&time, NULL);
1382   assert(status != -1, "linux error");
1383   return jlong(time.tv_sec) * 1000  +  jlong(time.tv_usec / 1000);
1384 }
1385 
1386 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {


4841 
4842     rc = sscanf(_uname.release,"%d.%d.%d", &major, &minor, &fix);
4843     if (rc == 3) {
4844 
4845       if (major < 256 && minor < 256 && fix < 256) {
4846         // Kernel version format is as expected,
4847         // set it overriding unknown state.
4848         _os_version = (major << 16) |
4849                       (minor << 8 ) |
4850                       (fix   << 0 ) ;
4851       }
4852     }
4853   }
4854 }
4855 
4856 uint32_t os::Linux::os_version() {
4857   assert(_os_version != 0, "not initialized");
4858   return _os_version & 0x00FFFFFF;
4859 }
4860 





4861 /////
4862 // glibc on Linux platform uses non-documented flag
4863 // to indicate, that some special sort of signal
4864 // trampoline is used.
4865 // We will never set this flag, and we should
4866 // ignore this flag in our diagnostic
4867 #ifdef SIGNIFICANT_SIGNAL_MASK
4868   #undef SIGNIFICANT_SIGNAL_MASK
4869 #endif
4870 #define SIGNIFICANT_SIGNAL_MASK (~0x04000000)
4871 
4872 static const char* get_signal_handler_name(address handler,
4873                                            char* buf, int buflen) {
4874   int offset = 0;
4875   bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
4876   if (found) {
4877     // skip directory names
4878     const char *p1, *p2;
4879     p1 = buf;
4880     size_t len = strlen(os::file_separator());


5439   }
5440 
5441   return active_cpus;
5442 }
5443 
5444 uint os::processor_id() {
5445   const int id = Linux::sched_getcpu();
5446   assert(id >= 0 && id < _processor_count, "Invalid processor id");
5447   return (uint)id;
5448 }
5449 
5450 void os::set_native_thread_name(const char *name) {
5451   if (Linux::_pthread_setname_np) {
5452     char buf [16]; // according to glibc manpage, 16 chars incl. '/0'
5453     snprintf(buf, sizeof(buf), "%s", name);
5454     buf[sizeof(buf) - 1] = '\0';
5455     const int rc = Linux::_pthread_setname_np(pthread_self(), buf);
5456     // ERANGE should not happen; all other errors should just be ignored.
5457     assert(rc != ERANGE, "pthread_setname_np failed");
5458   }





5459 }
5460 
5461 bool os::bind_to_processor(uint processor_id) {
5462   // Not yet implemented.
5463   return false;
5464 }
5465 
5466 ///
5467 
5468 void os::SuspendedThreadTask::internal_do_task() {
5469   if (do_suspend(_thread->osthread())) {
5470     SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
5471     do_task(context);
5472     do_resume(_thread->osthread());
5473   }
5474 }
5475 
5476 ////////////////////////////////////////////////////////////////////////////////
5477 // debug support
5478 


< prev index next >