mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-25 10:52:48 -06:00
k_system_control: Fix data race
`return distribution(gen)` is a data race between a read and a write in two threads, reported by TSan. Remove static random number generators so they aren't using the same generator.
This commit is contained in:
parent
983916e919
commit
b976cac49d
1 changed files with 3 additions and 3 deletions
|
@ -148,9 +148,9 @@ u64 GenerateUniformRange(u64 min, u64 max, F f) {
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
u64 KSystemControl::GenerateRandomU64() {
|
u64 KSystemControl::GenerateRandomU64() {
|
||||||
static std::random_device device;
|
std::random_device device;
|
||||||
static std::mt19937 gen(device());
|
std::mt19937 gen(device());
|
||||||
static std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
|
std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
|
||||||
return distribution(gen);
|
return distribution(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue