Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
dispatcher.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <memory>
7
9
10namespace contur {
11
12 class IClock;
13 class IExecutionEngine;
14 class IScheduler;
15 class ITracer;
16 class IVirtualMemory;
17 class SyscallTable;
18
23 class Dispatcher final : public IDispatcher
24 {
25 public:
28 IScheduler &scheduler,
29 IExecutionEngine &engine,
30 IVirtualMemory &virtualMemory,
31 IClock &clock,
32 ITracer &tracer,
33 SyscallTable &syscallTable
34 );
35
37 ~Dispatcher() override;
38
40 Dispatcher(const Dispatcher &) = delete;
41
43 Dispatcher &operator=(const Dispatcher &) = delete;
45 Dispatcher(Dispatcher &&) noexcept;
46
48 Dispatcher &operator=(Dispatcher &&) noexcept;
49
51 [[nodiscard]] Result<void> createProcess(std::unique_ptr<ProcessImage> process, Tick currentTick) override;
52
54 [[nodiscard]] Result<void> dispatch(std::size_t tickBudget) override;
55
57 [[nodiscard]] Result<void> terminateProcess(ProcessId pid, Tick currentTick) override;
58
60 void tick() override;
61
63 [[nodiscard]] std::size_t processCount() const noexcept override;
64
66 [[nodiscard]] bool hasProcess(ProcessId pid) const noexcept override;
67
68 private:
69 struct Impl;
70 std::unique_ptr<Impl> impl_;
71 };
72
73} // namespace contur
Dispatcher(Dispatcher &&) noexcept
Move-constructs dispatcher state.
void tick() override
Advances dispatcher clock by one tick.
~Dispatcher() override
Destroys dispatcher.
std::unique_ptr< Impl > impl_
Definition dispatcher.h:70
bool hasProcess(ProcessId pid) const noexcept override
Checks whether process id is currently managed.
Dispatcher & operator=(const Dispatcher &)=delete
Copy assignment is disabled.
Result< void > createProcess(std::unique_ptr< ProcessImage > process, Tick currentTick) override
Admits process and initializes memory/scheduler state.
Result< void > dispatch(std::size_t tickBudget) override
Executes one dispatch cycle for selected process.
std::size_t processCount() const noexcept override
Number of managed processes.
Dispatcher(IScheduler &scheduler, IExecutionEngine &engine, IVirtualMemory &virtualMemory, IClock &clock, ITracer &tracer, SyscallTable &syscallTable)
Constructs dispatcher from subsystem references.
Dispatcher(const Dispatcher &)=delete
Copy construction is disabled.
Result< void > terminateProcess(ProcessId pid, Tick currentTick) override
Terminates a process and reclaims associated resources.
Abstract clock interface for simulation time.
Definition clock.h:21
Interface for process lifecycle dispatch orchestration.
Abstract execution engine interface.
Scheduler abstraction managing process state queues.
Definition i_scheduler.h:24
Tracer interface used by kernel subsystems.
Definition i_tracer.h:17
Abstract interface for virtual memory management.
Full in-memory representation of a process.
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
Dispatch table mapping SyscallId to handler functions.
IDispatcher interface for process lifecycle orchestration.
Definition block.h:15
std::uint64_t Tick
Simulation clock tick counter.
Definition types.h:18
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12