Function GetRandomSeed: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Function | {{Function | ||
|prototype = unsigned int GetRandomSeed(void); | |prototype = unsigned int GetRandomSeed(void); | ||
|description = Obtain a truly random integer generated upon startup. This value is generated only once and should serve to seed a pseudo-random number generator function. The functionn uses the inherent entropy caused by the jitter of the ATmega644 internal watchdog timer RC timer vs the system's crystal. To be able to use this function, you must add "-DTRUE_RANDOM_GEN=1" to you makefile's KERNEL_OPTIONS variable. The generation of the random seed re | |description = Obtain a truly random integer generated upon startup. This value is generated only once and should serve to seed a pseudo-random number generator function. The functionn uses the inherent entropy caused by the jitter of the ATmega644 internal watchdog timer RC timer vs the system's crystal. To be able to use this function, you must add "-DTRUE_RANDOM_GEN=1" compile switch to you makefile's KERNEL_OPTIONS variable. The generation of the random seed re | ||
|parameters = | |parameters = | ||
|returns = Random seed generated only once at system's startup. | |returns = Random seed generated only once at system's startup. |
Revision as of 01:36, 12 September 2014
Prototype |
|
---|---|
Description |
Obtain a truly random integer generated upon startup. This value is generated only once and should serve to seed a pseudo-random number generator function. The functionn uses the inherent entropy caused by the jitter of the ATmega644 internal watchdog timer RC timer vs the system's crystal. To be able to use this function, you must add "-DTRUE_RANDOM_GEN=1" compile switch to you makefile's KERNEL_OPTIONS variable. The generation of the random seed re |
Parameters |
None |
Returns |
Random seed generated only once at system's startup. |
Video Modes |
N/A |
Since |
V3.3 |
Example:
int main(){ srand(GetRandomSeed()); ... //a truly random value will now be generated! int r=rand(); ... return 0; }