vCPUCore
The class "vCPUCore" serves as the implementation of CPU cores within the simulation. It includes two mandatory attributes: frequency and instructions-per-cycle, which determine the computational capacity of the core. The computational capacity is represented as a "Resource" object from the "Akatosh" library, enabling withdrawal or return of the available amount during the simulation. The "vCPUCore" is responsible for allocating the computational power to the assigned processes and reclaiming the distributed amount once the execution of the assigned process is complete. In the event that the "vCPUCore" is arbitrarily powered off during the simulation, all processes currently in execution will be considered as failed.
Bases: vHardwareComponent
Source code in PyCloudSim\entity\v_cpu_core.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
clock
property
Returns the clock of the CPU core, which is the continuous event that consumes instructions.
computational_power: Resource
property
Returns the computational power of the CPU core.
frequency: int
property
Returns the frequency of the CPU core.
instruction_cycle: float
property
Returns the time taken to execute one instruction.
instructions_queue
property
Returns the instructions queue of the CPU core.
ipc: int
property
Returns the number of instructions per cycle of the CPU core.
__init__(ipc, frequency, label=None, create_at=None, terminate_at=None, precursor=None)
Create a simulated CPU core.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ipc |
int | Callable
|
instructions per cycle. |
required |
frequency |
int | Callable
|
the frequency of the CPU core. |
required |
label |
str | None
|
the short description of the CPU Core. Defaults to None. |
None
|
create_at |
int | float | Callable[..., Any] | None
|
when this CPU core should be created. Defaults to None. |
None
|
terminate_at |
int | float | Callable[..., Any] | None
|
when this CPU core should be terminated. Defaults to None. |
None
|
precursor |
Entity | List[Entity] | None
|
the entity that this CPU core must not be created before. Defaults to None. |
None
|
Source code in PyCloudSim\entity\v_cpu_core.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
cache_instruction(instruction)
Cache instructions from a process to the CPU core.
Source code in PyCloudSim\entity\v_cpu_core.py
78 79 80 81 |
|
on_power_off()
Power off the CPU core.
Source code in PyCloudSim\entity\v_cpu_core.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
on_power_on()
Create the execution clock of the CPU core.
Source code in PyCloudSim\entity\v_cpu_core.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
usage(duration=None)
Returns the usage of the CPU core.
Source code in PyCloudSim\entity\v_cpu_core.py
132 133 134 |
|
utilization(duration=None)
Returns the utilization of the CPU core.
Source code in PyCloudSim\entity\v_cpu_core.py
136 137 138 |
|
Usage Example
from PyCloudSim.entity import vCPUCore
core = vCPUCore(
1, #IPC
4000, #Frequency in Mhz
"Core 0", # Label
0, # Created at 0s
)
# power on CPU core
core.power_on(at=0)
# power off CPU core
core.powere_off(at=10)
# terminate the CPU core
core.terminate(at=12)