py/scheduler: Add assert that scheduler is locked when unlocking.
And add a test that shows how this can happen when multiple threads are accessing the scheduler, which fails if atomic sections are not used.
This commit is contained in:
committed by
Damien George
parent
243805d776
commit
8470cd0be9
@@ -108,6 +108,7 @@ void mp_sched_lock(void) {
|
||||
|
||||
void mp_sched_unlock(void) {
|
||||
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();
|
||||
assert(MP_STATE_VM(sched_state) < 0);
|
||||
if (++MP_STATE_VM(sched_state) == 0) {
|
||||
// vm became unlocked
|
||||
if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL || mp_sched_num_pending()) {
|
||||
|
||||
Reference in New Issue
Block a user