1017 }
1018
1019 ////////////////////////////////////////////////////////////////////////////////
1020 // time support
1021
1022 // Time since start-up in seconds to a fine granularity.
1023 // Used by VMSelfDestructTimer and the MemProfiler.
1024 double os::elapsedTime() {
1025 return ((double)os::elapsed_counter()) / os::elapsed_frequency(); // nanosecond resolution
1026 }
1027
1028 jlong os::elapsed_counter() {
1029 return javaTimeNanos() - initial_time_count;
1030 }
1031
1032 jlong os::elapsed_frequency() {
1033 return NANOSECS_PER_SEC; // nanosecond resolution
1034 }
1035
1036 bool os::supports_vtime() { return true; }
1037 bool os::enable_vtime() { return false; }
1038 bool os::vtime_enabled() { return false; }
1039
1040 double os::elapsedVTime() {
1041 struct rusage usage;
1042 int retval = getrusage(RUSAGE_THREAD, &usage);
1043 if (retval == 0) {
1044 return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000.0 * 1000);
1045 } else {
1046 // better than nothing, but not much
1047 return elapsedTime();
1048 }
1049 }
1050
1051 jlong os::javaTimeMillis() {
1052 timeval time;
1053 int status = gettimeofday(&time, NULL);
1054 assert(status != -1, "aix error at gettimeofday()");
1055 return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
1056 }
1057
1058 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
3587 }
3588 };
3589
3590 int os::active_processor_count() {
3591 // User has overridden the number of active processors
3592 if (ActiveProcessorCount > 0) {
3593 log_trace(os)("active_processor_count: "
3594 "active processor count set by user : %d",
3595 ActiveProcessorCount);
3596 return ActiveProcessorCount;
3597 }
3598
3599 int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
3600 assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
3601 return online_cpus;
3602 }
3603
3604 void os::set_native_thread_name(const char *name) {
3605 // Not yet implemented.
3606 return;
3607 }
3608
3609 bool os::distribute_processes(uint length, uint* distribution) {
3610 // Not yet implemented.
3611 return false;
3612 }
3613
3614 bool os::bind_to_processor(uint processor_id) {
3615 // Not yet implemented.
3616 return false;
3617 }
3618
3619 void os::SuspendedThreadTask::internal_do_task() {
3620 if (do_suspend(_thread->osthread())) {
3621 SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
3622 do_task(context);
3623 do_resume(_thread->osthread());
3624 }
3625 }
3626
3627 ////////////////////////////////////////////////////////////////////////////////
3628 // debug support
3629
3630 bool os::find(address addr, outputStream* st) {
3631
|
1017 }
1018
1019 ////////////////////////////////////////////////////////////////////////////////
1020 // time support
1021
1022 // Time since start-up in seconds to a fine granularity.
1023 // Used by VMSelfDestructTimer and the MemProfiler.
1024 double os::elapsedTime() {
1025 return ((double)os::elapsed_counter()) / os::elapsed_frequency(); // nanosecond resolution
1026 }
1027
1028 jlong os::elapsed_counter() {
1029 return javaTimeNanos() - initial_time_count;
1030 }
1031
1032 jlong os::elapsed_frequency() {
1033 return NANOSECS_PER_SEC; // nanosecond resolution
1034 }
1035
1036 bool os::supports_vtime() { return true; }
1037
1038 double os::elapsedVTime() {
1039 struct rusage usage;
1040 int retval = getrusage(RUSAGE_THREAD, &usage);
1041 if (retval == 0) {
1042 return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000.0 * 1000);
1043 } else {
1044 // better than nothing, but not much
1045 return elapsedTime();
1046 }
1047 }
1048
1049 jlong os::javaTimeMillis() {
1050 timeval time;
1051 int status = gettimeofday(&time, NULL);
1052 assert(status != -1, "aix error at gettimeofday()");
1053 return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
1054 }
1055
1056 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
3585 }
3586 };
3587
3588 int os::active_processor_count() {
3589 // User has overridden the number of active processors
3590 if (ActiveProcessorCount > 0) {
3591 log_trace(os)("active_processor_count: "
3592 "active processor count set by user : %d",
3593 ActiveProcessorCount);
3594 return ActiveProcessorCount;
3595 }
3596
3597 int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
3598 assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
3599 return online_cpus;
3600 }
3601
3602 void os::set_native_thread_name(const char *name) {
3603 // Not yet implemented.
3604 return;
3605 }
3606
3607 bool os::bind_to_processor(uint processor_id) {
3608 // Not yet implemented.
3609 return false;
3610 }
3611
3612 void os::SuspendedThreadTask::internal_do_task() {
3613 if (do_suspend(_thread->osthread())) {
3614 SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext());
3615 do_task(context);
3616 do_resume(_thread->osthread());
3617 }
3618 }
3619
3620 ////////////////////////////////////////////////////////////////////////////////
3621 // debug support
3622
3623 bool os::find(address addr, outputStream* st) {
3624
|