Skip to content

Commit

Permalink
8261445: Use memory_order_relaxed for os::random().
Browse files Browse the repository at this point in the history
Reviewed-by: adinn, eosterlund, mdoerr, dholmes
  • Loading branch information
Andrew Haley committed Apr 20, 2021
1 parent 5136643 commit a25bae8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ int os::random() {
while (true) {
unsigned int seed = _rand_seed;
unsigned int rand = next_random(seed);
if (Atomic::cmpxchg(&_rand_seed, seed, rand) == seed) {
if (Atomic::cmpxchg(&_rand_seed, seed, rand, memory_order_relaxed) == seed) {
return static_cast<int>(rand);
}
}
Expand Down

0 comments on commit a25bae8

Please sign in to comment.