aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/prng.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-13 18:02:01 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-13 18:02:01 +0100
commit151edb44eea9bf25ec466133e9dbef87bd6b1372 (patch)
tree14537daf1be1896a5453dcff21593a4233f1c3b5 /src/kernel/core/prng.c
parent5bc7fcc00507bbc5ff5bf957a1589209f8495534 (diff)
downloadkogata-151edb44eea9bf25ec466133e9dbef87bd6b1372.tar.gz
kogata-151edb44eea9bf25ec466133e9dbef87bd6b1372.zip
Add missing mutex-locking in procesc.c ; discovered design fault somewhere.
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) {