contur2
Loading...
Searching...
No Matches
process_image.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <cstddef>
14#include <memory>
15#include <string>
16#include <vector>
17
18#include "contur/core/types.h"
19
20#include "contur/arch/block.h"
22#include "contur/process/pcb.h"
24
25namespace contur {
26
36 {
37 public:
45 ProcessId id,
46 std::string name,
47 std::vector<Block> code,
49 Tick arrivalTime = 0
50 );
51
53
54 // Non-copyable
55 ProcessImage(const ProcessImage &) = delete;
57
58 // Movable
60 ProcessImage &operator=(ProcessImage &&) noexcept;
61
63 [[nodiscard]] const PCB &pcb() const noexcept;
64
66 [[nodiscard]] PCB &pcb() noexcept;
67
69 [[nodiscard]] const RegisterFile &registers() const noexcept;
70
72 [[nodiscard]] RegisterFile &registers() noexcept;
73
75 [[nodiscard]] const std::vector<Block> &code() const noexcept;
76
78 [[nodiscard]] std::size_t codeSize() const noexcept;
79
84 [[nodiscard]] const Block &readCode(std::size_t offset) const;
85
88 void setCode(std::vector<Block> newCode);
89
91 [[nodiscard]] ProcessId id() const noexcept;
92
94 [[nodiscard]] std::string_view name() const noexcept;
95
97 [[nodiscard]] ProcessState state() const noexcept;
98
100 [[nodiscard]] const Priority &priority() const noexcept;
101
102 private:
103 struct Impl;
104 std::unique_ptr<Impl> impl_;
105 };
106
107} // namespace contur
Block — the fundamental unit of simulated memory.
Process Control Block — stores all metadata for a single process.
Definition pcb.h:55
ProcessState state() const noexcept
Returns the current process state.
const RegisterFile & registers() const noexcept
Returns a const reference to the register file.
const std::vector< Block > & code() const noexcept
Returns a const reference to the code segment.
std::size_t codeSize() const noexcept
Returns the size of the code segment (number of Blocks).
ProcessImage(ProcessImage &&) noexcept
void setCode(std::vector< Block > newCode)
Replaces the code segment with new code.
ProcessImage(const ProcessImage &)=delete
std::string_view name() const noexcept
Returns the process name.
std::unique_ptr< Impl > impl_
const Block & readCode(std::size_t offset) const
Reads a single Block from the code segment.
const Priority & priority() const noexcept
Returns the process priority.
ProcessImage & operator=(const ProcessImage &)=delete
const PCB & pcb() const noexcept
Returns a const reference to the PCB.
ProcessImage(ProcessId id, std::string name, std::vector< Block > code, Priority priority=Priority{}, Tick arrivalTime=0)
Constructs a ProcessImage with the given parameters.
The CPU's register bank — holds REGISTER_COUNT (16) registers.
Definition block.h:15
ProcessState
All possible states in a process lifecycle.
Definition state.h:29
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
Process Control Block — metadata for a single process.
Process priority levels and the Priority struct.
Register enum class and RegisterFile — the CPU's register bank.
A single memory cell in the simulated architecture.
Definition block.h:26
Composite priority descriptor for a process.
Definition priority.h:46
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...