You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
use crate::asm::data::literal::Value;
|
|
use std::time::Duration;
|
|
|
|
/// Cycles spent executing an instruction
|
|
pub type CyclesSpent = usize;
|
|
|
|
/// Result of execution evaluation (when Fault is not generated)
|
|
#[derive(Debug)]
|
|
pub struct EvalRes {
|
|
pub cycles: CyclesSpent,
|
|
pub advance: i64,
|
|
pub sched: SchedSignal,
|
|
}
|
|
|
|
impl Default for EvalRes {
|
|
fn default() -> Self {
|
|
Self {
|
|
cycles: 1,
|
|
advance: 1,
|
|
sched: SchedSignal::Normal,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Signal to the scheduler
|
|
#[derive(Debug)]
|
|
pub enum SchedSignal {
|
|
/// No signal, execution went normally.
|
|
Normal,
|
|
/// Yield control, optionally with a value.
|
|
/// If a value is yielded, it must be consumed through the handle before execution can resume.
|
|
Yield(Option<Value>),
|
|
/// The routine requests a delay in execution. The actual sleep time can be longer due to task
|
|
/// switching overhead.
|
|
Sleep(Duration),
|
|
/// Return from a coroutine - the thread ends and should be joined.
|
|
Ret(Vec<Value>),
|
|
/// Request to join a coroutine/thread
|
|
Join(Value),
|
|
}
|
|
|