From 43d00d645f104958e2365f4837a8d708bad60f15 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 27 Jul 2020 18:51:59 -0400 Subject: [PATCH] feat: tighten softint asserts in state transitions --- runtime/src/sandbox.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index 60675d0..9a53d04 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -544,7 +544,8 @@ void sandbox_set_as_runnable(struct sandbox *sandbox) { assert(sandbox); - assert(sandbox->last_state_change_timestamp > 0); + assert(!software_interrupt_is_enabled()); + uint64_t now = __getcycles(); uint64_t duration_of_last_state = now - sandbox->last_state_change_timestamp; sandbox_state_t last_state = sandbox->state; @@ -587,6 +588,8 @@ void sandbox_set_as_running(struct sandbox *sandbox) { assert(sandbox); + assert(!software_interrupt_is_enabled()); + uint64_t now = __getcycles(); uint64_t duration_of_last_state = now - sandbox->last_state_change_timestamp; sandbox_state_t last_state = sandbox->state; @@ -627,6 +630,8 @@ void sandbox_set_as_preempted(struct sandbox *sandbox) { assert(sandbox); + assert(!software_interrupt_is_enabled()); + uint64_t now = __getcycles(); uint64_t duration_of_last_state = now - sandbox->last_state_change_timestamp; sandbox_state_t last_state = sandbox->state; @@ -659,6 +664,8 @@ void sandbox_set_as_blocked(struct sandbox *sandbox) { assert(sandbox); + assert(!software_interrupt_is_enabled()); + uint64_t now = __getcycles(); uint64_t duration_of_last_state = now - sandbox->last_state_change_timestamp; sandbox_state_t last_state = sandbox->state; @@ -693,6 +700,8 @@ void sandbox_set_as_returned(struct sandbox *sandbox) { assert(sandbox); + assert(!software_interrupt_is_enabled()); + uint64_t now = __getcycles(); uint64_t duration_of_last_state = now - sandbox->last_state_change_timestamp; sandbox_state_t last_state = sandbox->state;