Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
native_engine.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#include <cstdint>
16#include <memory>
17#include <string>
18
20
21namespace contur {
22
23 class ITracer;
24
47 class NativeEngine final : public IExecutionEngine
48 {
49 public:
53 explicit NativeEngine(ITracer &tracer, std::uint32_t tickQuantumMs = 5);
54
56 ~NativeEngine() override;
57
58 // Non-copyable, movable.
59 NativeEngine(const NativeEngine &) = delete;
62 NativeEngine &operator=(NativeEngine &&) noexcept;
63
65 [[nodiscard]] ExecutionResult execute(ProcessImage &process, std::size_t tickBudget) override;
66
68 void halt(ProcessId pid) override;
69
71 [[nodiscard]] std::string_view name() const noexcept override;
72
75 [[nodiscard]] std::string capturedStdout(ProcessId pid) const;
76
78 [[nodiscard]] bool isTracking(ProcessId pid) const noexcept;
79
80 private:
81 struct Impl;
82 std::unique_ptr<Impl> impl_;
83 };
84
85} // namespace contur
Tracer interface used by kernel subsystems.
Definition i_tracer.h:17
std::unique_ptr< Impl > impl_
std::string_view name() const noexcept override
Returns the human-readable name of this engine.
~NativeEngine() override
Destroys the engine and forcibly terminates any surviving children.
NativeEngine(const NativeEngine &)=delete
NativeEngine & operator=(const NativeEngine &)=delete
bool isTracking(ProcessId pid) const noexcept
Returns true when the engine still tracks pid (process not yet reaped).
std::string capturedStdout(ProcessId pid) const
Returns the captured stdout for a process, or an empty string when unknown / not yet drained....
void halt(ProcessId pid) override
Forcibly halts execution of the given process.
NativeEngine(ITracer &tracer, std::uint32_t tickQuantumMs=5)
Constructs a NativeEngine.
NativeEngine(NativeEngine &&) noexcept
ExecutionResult execute(ProcessImage &process, std::size_t tickBudget) override
Executes the given process for up to tickBudget ticks.
Full in-memory representation of a process.
IExecutionEngine — abstract interface for process execution engines.
Definition block.h:15
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12
Result of an execution burst returned by IExecutionEngine::execute().