8234509: Race in macOS os::processor_id()
Reviewed-by: dholmes, pliden, rehn
This commit is contained in:
parent
48615b4ca9
commit
f4fced0e24
@ -3264,12 +3264,14 @@ uint os::processor_id() {
|
||||
int processor_id = Atomic::load(&mapping[apic_id]);
|
||||
|
||||
while (processor_id < 0) {
|
||||
if (Atomic::cmpxchg(-2, &mapping[apic_id], -1)) {
|
||||
if (Atomic::cmpxchg(-2, &mapping[apic_id], -1) == -1) {
|
||||
Atomic::store(Atomic::add(1, &next_processor_id) - 1, &mapping[apic_id]);
|
||||
}
|
||||
processor_id = Atomic::load(&mapping[apic_id]);
|
||||
}
|
||||
|
||||
assert(processor_id >= 0 && processor_id < os::processor_count(), "invalid processor id");
|
||||
|
||||
return (uint)processor_id;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user