![]() |
Contur 2
Educational OS kernel simulator
|
Native host-process execution engine. More...
#include <native_engine.h>
Public Member Functions | |
| NativeEngine (ITracer &tracer, std::uint32_t tickQuantumMs=5) | |
| Constructs a NativeEngine. | |
| ~NativeEngine () override | |
| Destroys the engine and forcibly terminates any surviving children. | |
| NativeEngine (const NativeEngine &)=delete | |
| NativeEngine & | operator= (const NativeEngine &)=delete |
| NativeEngine (NativeEngine &&) noexcept | |
| NativeEngine & | operator= (NativeEngine &&) noexcept |
| ExecutionResult | execute (ProcessImage &process, std::size_t tickBudget) override |
Executes the given process for up to tickBudget ticks. | |
| void | halt (ProcessId pid) override |
| Forcibly halts execution of the given process. | |
| std::string_view | name () const noexcept override |
| Returns the human-readable name of this engine. | |
| std::string | capturedStdout (ProcessId pid) const |
| Returns the captured stdout for a process, or an empty string when unknown / not yet drained. Useful for tests and demos. | |
| bool | isTracking (ProcessId pid) const noexcept |
Returns true when the engine still tracks pid (process not yet reaped). | |
| Public Member Functions inherited from contur::IExecutionEngine | |
| virtual | ~IExecutionEngine ()=default |
Private Attributes | |
| std::unique_ptr< Impl > | impl_ |
Additional Inherited Members | |
| Protected Member Functions inherited from contur::IExecutionEngine | |
| IExecutionEngine ()=default | |
| IExecutionEngine (const IExecutionEngine &)=default | |
| IExecutionEngine & | operator= (const IExecutionEngine &)=default |
| IExecutionEngine (IExecutionEngine &&)=default | |
| IExecutionEngine & | operator= (IExecutionEngine &&)=default |
Native host-process execution engine.
Reads ProcessImage::nativePath() on first dispatch for a given PID, spawns the host binary in a suspended state, and resumes / suspends the primary thread for each execute(...) burst. Stdout is captured via an anonymous pipe and surfaced through ITracer.
Behaviour summary:
NativeEngine is non-portable by design. On non-Windows hosts every method returns ExecutionResult::error(...). The class still compiles everywhere (the Win32 implementation is gated inside the .cpp).
Definition at line 47 of file native_engine.h.
|
explicit |
Constructs a NativeEngine.
| tracer | Reference to the simulator tracer (must outlive the engine). |
| tickQuantumMs | Wallclock milliseconds per simulation tick. |
Referenced by NativeEngine(), NativeEngine(), operator=(), and operator=().
|
override |
Destroys the engine and forcibly terminates any surviving children.
|
delete |
References NativeEngine().
|
noexcept |
References NativeEngine().
|
nodiscard |
Returns the captured stdout for a process, or an empty string when unknown / not yet drained. Useful for tests and demos.
References capturedStdout().
Referenced by capturedStdout().
|
nodiscardoverridevirtual |
Executes the given process for up to tickBudget ticks.
The engine runs the process until one of:
| process | The process image to execute (registers + code). |
| tickBudget | Maximum number of ticks (instructions) to execute. |
Implements contur::IExecutionEngine.
References execute().
Referenced by execute().
|
overridevirtual |
Forcibly halts execution of the given process.
| pid | The process ID to halt. |
Implements contur::IExecutionEngine.
References halt().
Referenced by halt().
|
nodiscardnoexcept |
Returns true when the engine still tracks pid (process not yet reaped).
References isTracking().
Referenced by isTracking().
|
nodiscardoverridevirtualnoexcept |
Returns the human-readable name of this engine.
Implements contur::IExecutionEngine.
References name().
Referenced by name().
|
delete |
References NativeEngine().
|
noexcept |
References NativeEngine().
|
private |
Definition at line 82 of file native_engine.h.