simulator: Add PRNG field
This commit is contained in:
+3
-1
@@ -70,14 +70,16 @@ const Task = struct {
|
||||
};
|
||||
|
||||
gpa: Allocator,
|
||||
prng: *std.Random.DefaultPrng,
|
||||
tasks: std.ArrayList(Task),
|
||||
regs: Registers,
|
||||
current_id: ?TaskID,
|
||||
current_time: u64,
|
||||
next_task_id: u64,
|
||||
|
||||
pub fn init(self: *Scheduler, gpa: Allocator) void {
|
||||
pub fn init(self: *Scheduler, gpa: Allocator, prng: *std.Random.DefaultPrng) void {
|
||||
self.gpa = gpa;
|
||||
self.prng = prng;
|
||||
self.tasks = .empty;
|
||||
self.current_id = null;
|
||||
self.current_time = 0;
|
||||
|
||||
+4
-2
@@ -25,15 +25,17 @@ const ExecutableName = struct {
|
||||
};
|
||||
|
||||
gpa: Allocator,
|
||||
prng: std.Random.DefaultPrng,
|
||||
scheduler: Scheduler,
|
||||
network: Network,
|
||||
nodes: std.ArrayList(*Node),
|
||||
executables: std.ArrayList(ExecutableName),
|
||||
real_io: std.Io,
|
||||
|
||||
pub fn init(self: *Simulator, gpa: Allocator, real_io: std.Io) void {
|
||||
pub fn init(self: *Simulator, gpa: Allocator, real_io: std.Io, seed: u64) void {
|
||||
self.gpa = gpa;
|
||||
self.scheduler.init(gpa);
|
||||
self.prng = std.Random.DefaultPrng.init(seed);
|
||||
self.scheduler.init(gpa, &self.prng);
|
||||
self.network.init(gpa);
|
||||
self.nodes = .empty;
|
||||
self.executables = .empty;
|
||||
|
||||
Reference in New Issue
Block a user