Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
i_scheduling_policy.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstdint>
7#include <string_view>
8#include <vector>
9
10#include "contur/core/types.h"
11
13
14namespace contur {
15
16 class IClock;
17
33
36 {
37 public:
38 virtual ~ISchedulingPolicy() = default;
39
41 [[nodiscard]] virtual std::string_view name() const noexcept = 0;
42
47 [[nodiscard]] virtual ProcessId
48 selectNext(const std::vector<SchedulingProcessSnapshot> &readyQueue, const IClock &clock) const = 0;
49
54 [[nodiscard]] virtual bool shouldPreempt(
55 const SchedulingProcessSnapshot &running, const SchedulingProcessSnapshot &candidate, const IClock &clock
56 ) const = 0;
57 };
58
59} // namespace contur
Abstract clock interface for simulation time.
Definition clock.h:21
Strategy interface for scheduling algorithms.
virtual bool shouldPreempt(const SchedulingProcessSnapshot &running, const SchedulingProcessSnapshot &candidate, const IClock &clock) const =0
Decides whether the current running process should be preempted.
virtual ~ISchedulingPolicy()=default
virtual ProcessId selectNext(const std::vector< SchedulingProcessSnapshot > &readyQueue, const IClock &clock) const =0
Selects the next process ID from the ready queue.
virtual std::string_view name() const noexcept=0
Human-readable policy name.
Definition block.h:15
PriorityLevel
Discrete priority levels, from highest (Realtime) to lowest (Idle).
Definition priority.h:20
@ Normal
Default priority for user processes.
Definition priority.h:24
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
constexpr ProcessId INVALID_PID
Sentinel value indicating an invalid/unassigned process ID.
Definition types.h:46
constexpr std::int32_t NICE_DEFAULT
Default nice value (no adjustment).
Definition priority.h:37
Process priority levels and the Priority struct.
Immutable process view consumed by scheduling policies.
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...