Skip to content

need APIs for ranged random number generation #6493

@andrewboie

Description

@andrewboie

Right now we just have sys_rand32_get() which returns a value between 0 and UINT_MAX.
Using a modulus operator (sys_rand32_get() % N) may not be the best practice to get a number in the range of 0...N:

https://stackoverflow.com/questions/2509679/how-to-generate-a-random-number-from-within-a-range/6852396#6852396

Implement an API in the random subsystem that does this right. Check the kernel codebase for example of the modulus pattern and replace with calls to this API.

Metadata

Metadata

Assignees

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: APIChanges to public APIs

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions