PUBLIC COMMENTS
> On 8/7/11 5:22 PM, David Holmes wrote:
>>
>> I seemed to have missed the discussion of this CR and the suggested fix. I
>> have a concern that this may cause compilation failures on some older
>> Linux systems because SYS_getcpu and/or __NR_vgetcpu will not exist. I
>> started trying to use sched_getcpu a few years back for the RTSJ 1.1
>> processor affinity API support that I started to prototype.
>> There were a number of issues on our main RT linux systems
>> because of the different statuses of the libc function and the
>> syscall. The code that I was intending to use was as follows:
>>
>> 32-bit:
>>
>> #ifndef SYS_getcpu
>> #define SYS_getcpu 318
>> #endif
>>
>> // Returns >= 0 for a processor id
>> // -1 if getcpu syscall is not supported
>> jint os::get_processor_id() {
>> unsigned int cpu = 0;
>> if (syscall(SYS_getcpu, &cpu, NULL, NULL) != -1) {
>> assert(cpu >= 0, "negative CPU id");
>> return (jint) cpu;
>> }
>> else {
>> return -1;
>> }
>> }
>>
>>
>> 64-bit: (sample from Novell/SuSE folk)
>>
>> #include <asm/vsyscall.h>
>>
>> #ifndef __NR_vgetcpu
>> #define __NR_vgetcpu 2
>> #endif
>>
>> int mygetcpu (unsigned *cpu, unsigned *node)
>> {
>> int (*p) (unsigned *cpu, unsigned *node, void *unused);
>> p = (void*)VSYSCALL_ADDR(__NR_vgetcpu);
>> return p (cpu, node, NULL);
>> }
>>
|