core: Add an "event queue" to threads using a ring buffer updated by the kernel
This commit is contained in:
parent
960699c984
commit
fb8de7b83b
@ -30,6 +30,7 @@ pub fn setupCore(allocator: *pmm.FrameAllocator) !void {
|
|||||||
idle_thread.regs = std.mem.zeroes(@TypeOf(idle_thread.regs));
|
idle_thread.regs = std.mem.zeroes(@TypeOf(idle_thread.regs));
|
||||||
idle_thread.state = .Running;
|
idle_thread.state = .Running;
|
||||||
idle_thread.user_priority = 0;
|
idle_thread.user_priority = 0;
|
||||||
|
idle_thread.event_queue = null;
|
||||||
thread.arch.initKernelRegisters(&idle_thread.regs);
|
thread.arch.initKernelRegisters(&idle_thread.regs);
|
||||||
thread.arch.setAddress(&idle_thread.regs, @intFromPtr(&thread.arch.idleLoop));
|
thread.arch.setAddress(&idle_thread.regs, @intFromPtr(&thread.arch.idleLoop));
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const system = @import("system");
|
||||||
const vmm = @import("arch/vmm.zig").arch;
|
const vmm = @import("arch/vmm.zig").arch;
|
||||||
const platform = @import("arch/platform.zig").arch;
|
const platform = @import("arch/platform.zig").arch;
|
||||||
const pmm = @import("pmm.zig");
|
const pmm = @import("pmm.zig");
|
||||||
const cpu = @import("arch/cpu.zig");
|
const cpu = @import("arch/cpu.zig");
|
||||||
const locking = @import("lib/spinlock.zig");
|
const locking = @import("lib/spinlock.zig");
|
||||||
|
|
||||||
|
const RingBuffer = system.ring_buffer.RingBuffer;
|
||||||
|
|
||||||
pub const arch = @import("arch/thread.zig").arch;
|
pub const arch = @import("arch/thread.zig").arch;
|
||||||
|
|
||||||
pub const ThreadState = enum {
|
pub const ThreadState = enum {
|
||||||
@ -20,6 +23,7 @@ pub const ThreadControlBlock = struct {
|
|||||||
regs: platform.Registers,
|
regs: platform.Registers,
|
||||||
state: ThreadState,
|
state: ThreadState,
|
||||||
user_priority: u8,
|
user_priority: u8,
|
||||||
|
event_queue: ?RingBuffer,
|
||||||
|
|
||||||
// Managed by addThreadToGlobalList(), no need to set manually.
|
// Managed by addThreadToGlobalList(), no need to set manually.
|
||||||
tag: GlobalThreadList.Node,
|
tag: GlobalThreadList.Node,
|
||||||
@ -146,6 +150,7 @@ pub fn createThreadControlBlock(allocator: *pmm.FrameAllocator) !*ThreadControlB
|
|||||||
thread.regs = std.mem.zeroes(@TypeOf(thread.regs));
|
thread.regs = std.mem.zeroes(@TypeOf(thread.regs));
|
||||||
thread.state = .Inactive;
|
thread.state = .Inactive;
|
||||||
thread.user_priority = 127;
|
thread.user_priority = 127;
|
||||||
|
thread.event_queue = null;
|
||||||
|
|
||||||
addThreadToGlobalList(thread);
|
addThreadToGlobalList(thread);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user