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();
|
||||
|
||||
init.state = .Running;
|
||||
thread.enterTask(init);
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,16 @@ const pmm = @import("pmm.zig");
|
||||
const cpu = @import("arch/cpu.zig");
|
||||
|
||||
pub const ThreadState = enum {
|
||||
Inactive,
|
||||
Running,
|
||||
Blocked,
|
||||
};
|
||||
|
||||
pub const ThreadControlBlock = struct {
|
||||
id: u64,
|
||||
directory: ?*vmm.PageDirectory,
|
||||
regs: interrupts.InterruptStackFrame,
|
||||
state: ThreadState,
|
||||
|
||||
ticks: u64,
|
||||
};
|
||||
@ -82,6 +85,7 @@ pub fn createThreadControlBlock(allocator: *pmm.FrameAllocator) !*ThreadControlB
|
||||
thread.id = next_id.fetchAdd(1, .seq_cst);
|
||||
thread.directory = null;
|
||||
thread.regs = std.mem.zeroes(@TypeOf(thread.regs));
|
||||
thread.state = .Inactive;
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user