contur2
Loading...
Searching...
No Matches
execution_context.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <cstddef>
11
12#include "contur/core/types.h"
13
15
16namespace contur {
17
27
37 {
40 std::size_t ticksConsumed = 0;
42
44 [[nodiscard]] static constexpr ExecutionResult budgetExhausted(ProcessId pid, std::size_t ticks) noexcept
45 {
47 }
48
50 [[nodiscard]] static constexpr ExecutionResult exited(ProcessId pid, std::size_t ticks) noexcept
51 {
53 }
54
56 [[nodiscard]] static constexpr ExecutionResult error(ProcessId pid, std::size_t ticks, Interrupt intr) noexcept
57 {
58 return ExecutionResult{StopReason::Error, intr, ticks, pid};
59 }
60
62 [[nodiscard]] static constexpr ExecutionResult
63 interrupted(ProcessId pid, std::size_t ticks, Interrupt intr) noexcept
64 {
65 return ExecutionResult{StopReason::Interrupted, intr, ticks, pid};
66 }
67
69 [[nodiscard]] static constexpr ExecutionResult halted(ProcessId pid, std::size_t ticks) noexcept
70 {
72 }
73 };
74
75} // namespace contur
Interrupt enum class — hardware and software interrupt codes.
Definition block.h:15
Interrupt
Interrupt codes used by the CPU and kernel.
Definition interrupt.h:17
@ Error
Generic error.
Definition interrupt.h:19
@ Ok
No interrupt — normal execution.
Definition interrupt.h:18
@ Exit
Process requests termination.
Definition interrupt.h:23
StopReason
Reason why the execution engine returned control to the dispatcher.
@ Interrupted
A software/hardware interrupt requires kernel attention (syscall, I/O, page fault).
@ BudgetExhausted
Tick budget ran out (preemption / time slice expired).
@ Halted
Process was forcibly halted via halt().
@ Error
An unrecoverable error occurred (invalid instruction, segfault, etc.).
@ ProcessExited
Process executed Halt or Int Exit — normal termination.
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12
constexpr ProcessId INVALID_PID
Sentinel value indicating an invalid/unassigned process ID.
Definition types.h:46
Result of an execution burst returned by IExecutionEngine::execute().
static constexpr ExecutionResult error(ProcessId pid, std::size_t ticks, Interrupt intr) noexcept
Creates a result for an error condition.
ProcessId pid
The process that was executing.
std::size_t ticksConsumed
Number of ticks actually executed.
static constexpr ExecutionResult budgetExhausted(ProcessId pid, std::size_t ticks) noexcept
Creates a result for budget exhaustion (preemption).
static constexpr ExecutionResult exited(ProcessId pid, std::size_t ticks) noexcept
Creates a result for normal process exit.
StopReason reason
Why execution stopped.
Interrupt interrupt
The interrupt that caused the stop (if Interrupted).
static constexpr ExecutionResult interrupted(ProcessId pid, std::size_t ticks, Interrupt intr) noexcept
Creates a result for an interrupt requiring kernel attention.
static constexpr ExecutionResult halted(ProcessId pid, std::size_t ticks) noexcept
Creates a result for a forcibly halted process.
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...