contur2
Loading...
Searching...
No Matches
mlfq_policy.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstddef>
7#include <vector>
8
10
11namespace contur {
12
17 class MlfqPolicy final : public ISchedulingPolicy
18 {
19 public:
22 explicit MlfqPolicy(std::vector<std::size_t> levelTimeSlices = {1, 2, 4});
23
25 [[nodiscard]] std::string_view name() const noexcept override;
26
28 [[nodiscard]] ProcessId selectNext(
29 const std::vector<std::reference_wrapper<const PCB>> &readyQueue, const IClock &clock
30 ) const override;
31
33 [[nodiscard]] bool shouldPreempt(const PCB &running, const PCB &candidate, const IClock &clock) const override;
34
36 [[nodiscard]] const std::vector<std::size_t> &levelTimeSlices() const noexcept;
37
38 private:
39 std::vector<std::size_t> levelTimeSlices_;
40 };
41
42} // namespace contur
Abstract clock interface for simulation time.
Definition clock.h:21
Strategy interface for scheduling algorithms.
ProcessId selectNext(const std::vector< std::reference_wrapper< const PCB > > &readyQueue, const IClock &clock) const override
Selects next process according to MLFQ level ordering.
MlfqPolicy(std::vector< std::size_t > levelTimeSlices={1, 2, 4})
Constructs MLFQ policy.
const std::vector< std::size_t > & levelTimeSlices() const noexcept
Configured level time slices.
bool shouldPreempt(const PCB &running, const PCB &candidate, const IClock &clock) const override
Returns true when running process should be preempted.
std::vector< std::size_t > levelTimeSlices_
Definition mlfq_policy.h:39
std::string_view name() const noexcept override
Policy name.
Process Control Block — stores all metadata for a single process.
Definition pcb.h:55
ISchedulingPolicy interface for pluggable scheduling algorithms.
Definition block.h:15
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12