aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/prng.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/core/prng.c')
-rw-r--r--src/kernel/core/prng.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/kernel/core/prng.c b/src/kernel/core/prng.c
index dbffba5..77dff7d 100644
--- a/src/kernel/core/prng.c
+++ b/src/kernel/core/prng.c
@@ -11,6 +11,8 @@ static const uint32_t a = 16807;
static const uint32_t m = 0x7FFFFFFF;
uint16_t prng_word() {
+ int st = enter_critical(CL_NOINT);
+
if (++n >= 100) {
n = 0;
if (entropy_count) {
@@ -18,7 +20,12 @@ uint16_t prng_word() {
}
}
x = (x * a) % m;
- return x & 0xFFFF;
+
+ uint16_t ret = x & 0xFFFF;
+
+ exit_critical(st);
+
+ return ret;
}
void prng_bytes(uint8_t* out, size_t nbytes) {