Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
round_robin_policy.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstddef>
7
9
10namespace contur {
11
17 {
18 public:
21 explicit RoundRobinPolicy(std::size_t timeSlice);
22
24 [[nodiscard]] std::string_view name() const noexcept override;
25
27 [[nodiscard]] ProcessId
28 selectNext(const std::vector<SchedulingProcessSnapshot> &readyQueue, const IClock &clock) const override;
29
31 [[nodiscard]] bool shouldPreempt(
32 const SchedulingProcessSnapshot &running, const SchedulingProcessSnapshot &candidate, const IClock &clock
33 ) const override;
34
36 [[nodiscard]] std::size_t timeSlice() const noexcept;
37
38 private:
39 std::size_t timeSlice_;
40 };
41
42} // namespace contur
Abstract clock interface for simulation time.
Definition clock.h:21
Strategy interface for scheduling algorithms.
bool shouldPreempt(const SchedulingProcessSnapshot &running, const SchedulingProcessSnapshot &candidate, const IClock &clock) const override
Returns true if running process exhausted its slice.
ProcessId selectNext(const std::vector< SchedulingProcessSnapshot > &readyQueue, const IClock &clock) const override
Selects the next process in round-robin queue order.
std::string_view name() const noexcept override
Policy name.
std::size_t timeSlice() const noexcept
Configured time slice.
RoundRobinPolicy(std::size_t timeSlice)
Constructs Round Robin policy.
ISchedulingPolicy interface for pluggable scheduling algorithms.
Definition block.h:15
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12
Immutable process view consumed by scheduling policies.