|
|
@ -653,6 +653,39 @@ sandbox_set_as_preempted(struct sandbox *sandbox)
|
|
|
|
sandbox->state = SANDBOX_PREEMPTED;
|
|
|
|
sandbox->state = SANDBOX_PREEMPTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Transitions a sandbox to the SANDBOX_BLOCKED state.
|
|
|
|
|
|
|
|
* This occurs when a sandbox is executing and it makes a blocking API call of some kind.
|
|
|
|
|
|
|
|
* Automatically removes the sandbox from the runqueue
|
|
|
|
|
|
|
|
* @param sandbox the blocking sandbox
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
sandbox_set_as_blocked(struct sandbox *sandbox)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
assert(sandbox);
|
|
|
|
|
|
|
|
uint64_t now = __getcycles();
|
|
|
|
|
|
|
|
uint64_t duration_of_last_state = now - sandbox->last_state_change_timestamp;
|
|
|
|
|
|
|
|
sandbox_state_t last_state = sandbox->state;
|
|
|
|
|
|
|
|
sandbox->state = SANDBOX_SET_AS_BLOCKED;
|
|
|
|
|
|
|
|
debuglog("Thread %lu | Sandbox %lu | %s => Blocked\n", pthread_self(), sandbox->allocation_timestamp,
|
|
|
|
|
|
|
|
sandbox_state_stringify(last_state));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (last_state) {
|
|
|
|
|
|
|
|
case SANDBOX_RUNNING: {
|
|
|
|
|
|
|
|
sandbox->running_duration += duration_of_last_state;
|
|
|
|
|
|
|
|
local_runqueue_delete(sandbox);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
|
|
|
|
panic("Thread %lu | Sandbox %lu | Illegal transition from %s to Blocked\n", pthread_self(),
|
|
|
|
|
|
|
|
sandbox->allocation_timestamp, sandbox_state_stringify(last_state));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sandbox->last_state_change_timestamp = now;
|
|
|
|
|
|
|
|
sandbox->state = SANDBOX_BLOCKED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Transitions a sandbox from the SANDBOX_RETURNED state to the SANDBOX_COMPLETE state.
|
|
|
|
* Transitions a sandbox from the SANDBOX_RETURNED state to the SANDBOX_COMPLETE state.
|
|
|
|
* Adds the sandbox to the completion queue
|
|
|
|
* Adds the sandbox to the completion queue
|
|
|
|