Skip to content

Key PseudorandomNumberGenerator by thread name to survive CPU thread recreation#212

Open
mananni-silabs wants to merge 1 commit into
renode:masterfrom
SiliconLabsSoftware:bugfix/pseudo_rng
Open

Key PseudorandomNumberGenerator by thread name to survive CPU thread recreation#212
mananni-silabs wants to merge 1 commit into
renode:masterfrom
SiliconLabsSoftware:bugfix/pseudo_rng

Conversation

@mananni-silabs

Copy link
Copy Markdown
Contributor

The generator is ThreadLocal and seeds each thread's Random solely from the thread name (name.Sum() ^ baseSeed). ThreadLocal, however, keys by the physical managed thread. CPU cores that halt and resume (e.g. a power-managed radio sequencer) have their dispatcher thread torn down on halt and recreated under the same name on resume, so each recreation built a fresh Random with an identical seed and restarted the pseudo-random stream from the beginning.

Cache RandomGenerator instances by logical thread name so a thread recreated under the same name continues its existing, deterministic stream, and clear the cache in ResetSeed. Determinism is preserved because the recreation count is itself deterministic for a given seed.

…recreation

The generator is ThreadLocal and seeds each thread's Random solely from the
thread name (name.Sum() ^ baseSeed). ThreadLocal, however, keys by the physical
managed thread. CPU cores that halt and resume (e.g. a power-managed radio
sequencer) have their dispatcher thread torn down on halt and recreated under
the same name on resume, so each recreation built a fresh Random with an
identical seed and restarted the pseudo-random stream from the beginning.

Cache RandomGenerator instances by logical thread name so a thread recreated
under the same name continues its existing, deterministic stream, and clear the
cache in ResetSeed. Determinism is preserved because the recreation count is
itself deterministic for a given seed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant