comparison src/os/windows/vm/os_windows.cpp @ 14475:6c9332549827

6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler Reviewed-by: dholmes, dcubed
author fparain
date Wed, 19 Feb 2014 16:22:15 +0000
parents b59507f713e0
children d8041d695d19 f6301b007a16
comparison
equal deleted inserted replaced
14474:de7f1b016d55 14475:6c9332549827
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
626 CloseHandle(osthread->thread_handle()); 626 CloseHandle(osthread->thread_handle());
627 CloseHandle(osthread->interrupt_event()); 627 CloseHandle(osthread->interrupt_event());
628 delete osthread; 628 delete osthread;
629 } 629 }
630 630
631
632 static int has_performance_count = 0;
633 static jlong first_filetime; 631 static jlong first_filetime;
634 static jlong initial_performance_count; 632 static jlong initial_performance_count;
635 static jlong performance_frequency; 633 static jlong performance_frequency;
636 634
637 635
643 } 641 }
644 642
645 643
646 jlong os::elapsed_counter() { 644 jlong os::elapsed_counter() {
647 LARGE_INTEGER count; 645 LARGE_INTEGER count;
648 if (has_performance_count) { 646 if (win32::_has_performance_count) {
649 QueryPerformanceCounter(&count); 647 QueryPerformanceCounter(&count);
650 return as_long(count) - initial_performance_count; 648 return as_long(count) - initial_performance_count;
651 } else { 649 } else {
652 FILETIME wt; 650 FILETIME wt;
653 GetSystemTimeAsFileTime(&wt); 651 GetSystemTimeAsFileTime(&wt);
655 } 653 }
656 } 654 }
657 655
658 656
659 jlong os::elapsed_frequency() { 657 jlong os::elapsed_frequency() {
660 if (has_performance_count) { 658 if (win32::_has_performance_count) {
661 return performance_frequency; 659 return performance_frequency;
662 } else { 660 } else {
663 // the FILETIME time is the number of 100-nanosecond intervals since January 1,1601. 661 // the FILETIME time is the number of 100-nanosecond intervals since January 1,1601.
664 return 10000000; 662 return 10000000;
665 } 663 }
734 bool os::bind_to_processor(uint processor_id) { 732 bool os::bind_to_processor(uint processor_id) {
735 // Not yet implemented. 733 // Not yet implemented.
736 return false; 734 return false;
737 } 735 }
738 736
739 static void initialize_performance_counter() { 737 void os::win32::initialize_performance_counter() {
740 LARGE_INTEGER count; 738 LARGE_INTEGER count;
741 if (QueryPerformanceFrequency(&count)) { 739 if (QueryPerformanceFrequency(&count)) {
742 has_performance_count = 1; 740 win32::_has_performance_count = 1;
743 performance_frequency = as_long(count); 741 performance_frequency = as_long(count);
744 QueryPerformanceCounter(&count); 742 QueryPerformanceCounter(&count);
745 initial_performance_count = as_long(count); 743 initial_performance_count = as_long(count);
746 } else { 744 } else {
747 has_performance_count = 0; 745 win32::_has_performance_count = 0;
748 FILETIME wt; 746 FILETIME wt;
749 GetSystemTimeAsFileTime(&wt); 747 GetSystemTimeAsFileTime(&wt);
750 first_filetime = jlong_from(wt.dwHighDateTime, wt.dwLowDateTime); 748 first_filetime = jlong_from(wt.dwHighDateTime, wt.dwLowDateTime);
751 } 749 }
752 } 750 }
837 return windows_to_java_time(wt); 835 return windows_to_java_time(wt);
838 } 836 }
839 } 837 }
840 838
841 jlong os::javaTimeNanos() { 839 jlong os::javaTimeNanos() {
842 if (!has_performance_count) { 840 if (!win32::_has_performance_count) {
843 return javaTimeMillis() * NANOSECS_PER_MILLISEC; // the best we can do. 841 return javaTimeMillis() * NANOSECS_PER_MILLISEC; // the best we can do.
844 } else { 842 } else {
845 LARGE_INTEGER current_count; 843 LARGE_INTEGER current_count;
846 QueryPerformanceCounter(&current_count); 844 QueryPerformanceCounter(&current_count);
847 double current = as_long(current_count); 845 double current = as_long(current_count);
850 return time; 848 return time;
851 } 849 }
852 } 850 }
853 851
854 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { 852 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
855 if (!has_performance_count) { 853 if (!win32::_has_performance_count) {
856 // javaTimeMillis() doesn't have much percision, 854 // javaTimeMillis() doesn't have much percision,
857 // but it is not going to wrap -- so all 64 bits 855 // but it is not going to wrap -- so all 64 bits
858 info_ptr->max_value = ALL_64_BITS; 856 info_ptr->max_value = ALL_64_BITS;
859 857
860 // this is a wall clock timer, so may skip 858 // this is a wall clock timer, so may skip
3680 3678
3681 bool os::win32::_is_nt = false; 3679 bool os::win32::_is_nt = false;
3682 bool os::win32::_is_windows_2003 = false; 3680 bool os::win32::_is_windows_2003 = false;
3683 bool os::win32::_is_windows_server = false; 3681 bool os::win32::_is_windows_server = false;
3684 3682
3683 bool os::win32::_has_performance_count = 0;
3684
3685 void os::win32::initialize_system_info() { 3685 void os::win32::initialize_system_info() {
3686 SYSTEM_INFO si; 3686 SYSTEM_INFO si;
3687 GetSystemInfo(&si); 3687 GetSystemInfo(&si);
3688 _vm_page_size = si.dwPageSize; 3688 _vm_page_size = si.dwPageSize;
3689 _vm_allocation_granularity = si.dwAllocationGranularity; 3689 _vm_allocation_granularity = si.dwAllocationGranularity;