1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
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 *
699 bool os::has_allocatable_memory_limit(julong* limit) {
700 MEMORYSTATUSEX ms;
701 ms.dwLength = sizeof(ms);
702 GlobalMemoryStatusEx(&ms);
703 #ifdef _LP64
704 *limit = (julong)ms.ullAvailVirtual;
705 return true;
706 #else
707 // Limit to 1400m because of the 2gb address space wall
708 *limit = MIN2((julong)1400*M, (julong)ms.ullAvailVirtual);
709 return true;
710 #endif
711 }
712
713 // VC6 lacks DWORD_PTR
714 #if _MSC_VER < 1300
715 typedef UINT_PTR DWORD_PTR;
716 #endif
717
718 int os::active_processor_count() {
719 DWORD_PTR lpProcessAffinityMask = 0;
720 DWORD_PTR lpSystemAffinityMask = 0;
721 int proc_count = processor_count();
722 if (proc_count <= sizeof(UINT_PTR) * BitsPerByte &&
723 GetProcessAffinityMask(GetCurrentProcess(), &lpProcessAffinityMask, &lpSystemAffinityMask)) {
724 // Nof active processors is number of bits in process affinity mask
725 int bitcount = 0;
726 while (lpProcessAffinityMask != 0) {
727 lpProcessAffinityMask = lpProcessAffinityMask & (lpProcessAffinityMask-1);
728 bitcount++;
729 }
730 return bitcount;
731 } else {
732 return proc_count;
733 }
734 }
735
736 void os::set_native_thread_name(const char *name) {
737 // Not yet implemented.
738 return;
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
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 *
699 bool os::has_allocatable_memory_limit(julong* limit) {
700 MEMORYSTATUSEX ms;
701 ms.dwLength = sizeof(ms);
702 GlobalMemoryStatusEx(&ms);
703 #ifdef _LP64
704 *limit = (julong)ms.ullAvailVirtual;
705 return true;
706 #else
707 // Limit to 1400m because of the 2gb address space wall
708 *limit = MIN2((julong)1400*M, (julong)ms.ullAvailVirtual);
709 return true;
710 #endif
711 }
712
713 // VC6 lacks DWORD_PTR
714 #if _MSC_VER < 1300
715 typedef UINT_PTR DWORD_PTR;
716 #endif
717
718 int os::active_processor_count() {
719 // User has overridden the number of active processors
720 if (ActiveProcessorCount > 0) {
721 if (PrintActiveCpus) {
722 tty->print_cr("active_processor_count: "
723 "active processor count set by user : %d",
724 ActiveProcessorCount);
725 }
726 return ActiveProcessorCount;
727 }
728
729 DWORD_PTR lpProcessAffinityMask = 0;
730 DWORD_PTR lpSystemAffinityMask = 0;
731 int proc_count = processor_count();
732 if (proc_count <= sizeof(UINT_PTR) * BitsPerByte &&
733 GetProcessAffinityMask(GetCurrentProcess(), &lpProcessAffinityMask, &lpSystemAffinityMask)) {
734 // Nof active processors is number of bits in process affinity mask
735 int bitcount = 0;
736 while (lpProcessAffinityMask != 0) {
737 lpProcessAffinityMask = lpProcessAffinityMask & (lpProcessAffinityMask-1);
738 bitcount++;
739 }
740 return bitcount;
741 } else {
742 return proc_count;
743 }
744 }
745
746 void os::set_native_thread_name(const char *name) {
747 // Not yet implemented.
748 return;
|