mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 01:54:47 +02:00
8203227: Introduce os::processor_id() for Linux and Solaris
Reviewed-by: dholmes, rehn
This commit is contained in:
parent
ab469d40fc
commit
dface12e6d
3 changed files with 20 additions and 0 deletions
|
@ -2872,6 +2872,10 @@ void os::Linux::sched_getcpu_init() {
|
|||
set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
|
||||
(void*)&sched_getcpu_syscall));
|
||||
}
|
||||
|
||||
if (sched_getcpu() == -1) {
|
||||
vm_exit_during_initialization("getcpu(2) system call not supported by kernel");
|
||||
}
|
||||
}
|
||||
|
||||
// Something to do with the numa-aware allocator needs these symbols
|
||||
|
@ -5229,6 +5233,12 @@ int os::active_processor_count() {
|
|||
return active_cpus;
|
||||
}
|
||||
|
||||
uint os::processor_id() {
|
||||
const int id = Linux::sched_getcpu();
|
||||
assert(id >= 0 && id < _processor_count, "Invalid processor id");
|
||||
return (uint)id;
|
||||
}
|
||||
|
||||
void os::set_native_thread_name(const char *name) {
|
||||
if (Linux::_pthread_setname_np) {
|
||||
char buf [16]; // according to glibc manpage, 16 chars incl. '/0'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue