core: Add thread states
This commit is contained in:
parent
f87426753b
commit
4554bce8a8
@ -106,6 +106,7 @@ export fn _start(magic: u32, info: MultibootInfo) callconv(.C) noreturn {
|
|||||||
|
|
||||||
platform.platformEndInit();
|
platform.platformEndInit();
|
||||||
|
|
||||||
|
init.state = .Running;
|
||||||
thread.enterTask(init);
|
thread.enterTask(init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,13 +6,16 @@ const pmm = @import("pmm.zig");
|
|||||||
const cpu = @import("arch/cpu.zig");
|
const cpu = @import("arch/cpu.zig");
|
||||||
|
|
||||||
pub const ThreadState = enum {
|
pub const ThreadState = enum {
|
||||||
|
Inactive,
|
||||||
Running,
|
Running,
|
||||||
|
Blocked,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ThreadControlBlock = struct {
|
pub const ThreadControlBlock = struct {
|
||||||
id: u64,
|
id: u64,
|
||||||
directory: ?*vmm.PageDirectory,
|
directory: ?*vmm.PageDirectory,
|
||||||
regs: interrupts.InterruptStackFrame,
|
regs: interrupts.InterruptStackFrame,
|
||||||
|
state: ThreadState,
|
||||||
|
|
||||||
ticks: u64,
|
ticks: u64,
|
||||||
};
|
};
|
||||||
@ -82,6 +85,7 @@ pub fn createThreadControlBlock(allocator: *pmm.FrameAllocator) !*ThreadControlB
|
|||||||
thread.id = next_id.fetchAdd(1, .seq_cst);
|
thread.id = next_id.fetchAdd(1, .seq_cst);
|
||||||
thread.directory = null;
|
thread.directory = null;
|
||||||
thread.regs = std.mem.zeroes(@TypeOf(thread.regs));
|
thread.regs = std.mem.zeroes(@TypeOf(thread.regs));
|
||||||
|
thread.state = .Inactive;
|
||||||
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user