mirror of
https://github.com/QuantumLeaps/qpc.git
synced 2025-01-14 06:43:19 +08:00
15 lines
424 B
C
15 lines
424 B
C
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
|
|
uint32_t rnd;
|
|
QSchedStatus lockStat;
|
|
|
|
lockStat = QXK_schedLock(N_PHILO); /* lock scheduler around shared seed */
|
|
|
|
/* "Super-Duper" Linear Congruential Generator (LCG) */
|
|
rnd = l_rnd * (3U*7U*11U*13U*23U);
|
|
l_rnd = rnd; /* set for the next time */
|
|
|
|
QXK_schedLock(lockStat); /* unlock the scheduler */
|
|
|
|
return rnd;
|
|
}
|