RFR: os::processor_id() for Mac OS X

Per Liden per.liden at oracle.com
Fri Mar 9 15:01:13 UTC 2018


Hi Gerard,

We don't need it at this time. We'll add it if we decide to support such 
a port.

/Per

On 03/09/2018 03:32 PM, Gerard Ziemski wrote:
> Ping,
> 
> Do we need https://bugs.openjdk.java.net/browse/JDK-8199415 “Implement os::processor_id() on Mac OS X” ?
> 
> 
> cheers
> 
>> On Jan 17, 2018, at 11:01 AM, Gerard Ziemski <gerard.ziemski at oracle.com> wrote:
>>
>> hi all,
>>
>> Please review this simple feature adding os::processor_id() implementation for Mac OS X:
>>
>> http://cr.openjdk.java.net/~gziemski/zgc_os_processor_id/webrev/src/hotspot/os/bsd/os_bsd.cpp.udiff.html <http://cr.openjdk.java.net/~gziemski/zgc_os_processor_id/webrev/src/hotspot/os/bsd/os_bsd.cpp.udiff.html>
>>
>> Here is a standalone test using such implementation:
>>
>> #include <stdio.h>
>> #include <unistd.h>
>> #include <cpuid.h>
>> #include <pthread.h>
>>
>> int get_cpu_id() {
>>   uint32_t EAX = 0; // must be set to 0
>>   uint32_t EBX = 0;
>>   uint32_t ECX = 0;
>>   uint32_t EDX = 0;
>>   __cpuid(1, EAX, EBX, ECX, EDX);
>>   // Check EDX for Advanced Programmable Interrupt Controller
>>   if ((EDX & bit_APIC) != 0) {
>>     // EBX[bits 31:24] Local APIC ID: The initial APIC-ID is used to identify the executing logical processor.
>>     return (EBX >> 24) & 0xFF;
>>   }
>>   return 0;
>> }
>>
>> void *tick(void *void_ptr)
>> {
>>   int thread_id = *((int *)void_ptr);
>>   for (int i=0; i<10; i++) {
>>     printf("thread: %2d running on cpu: %d\n", thread_id, get_cpu_id());
>>     sleep(1);
>>   }
>>   return NULL;
>> }
>>
>> int main(int argc, const char * argv[]) {
>>   int count = 32;
>>   pthread_t thread[count];
>>   for (int i=0; i<count; i++) {
>>     pthread_create(&thread[i], NULL, tick, &i);
>>   }
>>   for (int i=0; i<count; i++) {
>>     pthread_join(thread[i], NULL);
>>   }
>>   return 0;
>> }
>>
>> -------------------------------------------
>> Outputs:
>>
>> thread:  2 running on cpu: 4
>> thread:  3 running on cpu: 5
>> thread:  4 running on cpu: 2
>> thread:  6 running on cpu: 1
>> thread:  6 running on cpu: 5
>> thread:  7 running on cpu: 1
>> thread:  8 running on cpu: 7
>> thread:  9 running on cpu: 5
>> thread:  9 running on cpu: 7
>> thread: 10 running on cpu: 3
>> thread: 11 running on cpu: 3
>> thread: 12 running on cpu: 2
>> thread: 13 running on cpu: 3
>> thread: 15 running on cpu: 1
>> thread: 16 running on cpu: 3
>> thread: 17 running on cpu: 7
>> thread: 18 running on cpu: 3
>> thread: 19 running on cpu: 5
>> thread: 19 running on cpu: 2
>> thread: 21 running on cpu: 2
>> thread: 22 running on cpu: 7
>>>>
>> cheers
> 


More information about the zgc-dev mailing list