diff options
author | Uros Majstorovic <majstor@majstor.org> | 2018-03-16 14:15:39 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2018-03-16 14:15:39 +0100 |
commit | b1c3ee27894d33d9fcfca4ea4d0ccfb6d4cfc83e (patch) | |
tree | 16bfe6ba0da03cf94dec735076d2de1eac9fc761 /code/fe310/eos/event.c | |
parent | 8755ad4c0b0652f16d3505ed72ed3d8310a35c6f (diff) |
fixed race conditions
Diffstat (limited to 'code/fe310/eos/event.c')
-rw-r--r-- | code/fe310/eos/event.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/code/fe310/eos/event.c b/code/fe310/eos/event.c index a1cf591..127e45a 100644 --- a/code/fe310/eos/event.c +++ b/code/fe310/eos/event.c @@ -26,11 +26,16 @@ void eos_evtq_init(void) { } int eos_evtq_push(unsigned char cmd, unsigned char *buffer, uint16_t len) { - return eos_msgq_push(&_eos_event_q, cmd, buffer, len); + clear_csr(mstatus, MSTATUS_MIE); + int ret = eos_msgq_push(&_eos_event_q, cmd, buffer, len); + set_csr(mstatus, MSTATUS_MIE); + return ret; } void eos_evtq_pop(unsigned char *cmd, unsigned char **buffer, uint16_t *len) { + clear_csr(mstatus, MSTATUS_MIE); eos_msgq_pop(&_eos_event_q, cmd, buffer, len); + set_csr(mstatus, MSTATUS_MIE); } void eos_evtq_bad_handler(unsigned char cmd, unsigned char *buffer, uint16_t len) { @@ -71,7 +76,7 @@ void eos_evtq_loop(void) { while(foo) { clear_csr(mstatus, MSTATUS_MIE); - eos_evtq_pop(&cmd, &buffer, &len); + eos_msgq_pop(&_eos_event_q, &cmd, &buffer, &len); if (cmd) { set_csr(mstatus, MSTATUS_MIE); eos_evtq_handle(cmd, buffer, len); |