init: Calculate the number of threads loaded

This will be quite useful in the future.
This commit is contained in:
Gabriel 2025-02-24 19:18:51 +01:00
parent 0b32214f0e
commit 23334004a5

View File

@ -25,22 +25,22 @@ fn setTokens() void {
syscalls.setTokens(syscalls.getThreadId(), tokens) catch {}; syscalls.setTokens(syscalls.getThreadId(), tokens) catch {};
} }
fn discoverThreadLimit() u64 {
var pid: u64 = 1;
while (true) {
_ = syscalls.getPriority(pid) catch return (pid - 1);
pid += 1;
}
}
export fn _start(base: u64, address: u64) callconv(.C) noreturn { export fn _start(base: u64, address: u64) callconv(.C) noreturn {
setTokens(); setTokens();
const mapper = vm.MemoryMapper.create(.{ .address = address }, base); const mapper = vm.MemoryMapper.create(.{ .address = address }, base);
_ = mapper;
syscalls.print(base); const threads = discoverThreadLimit();
syscalls.print(address); syscalls.print(threads);
syscalls.print(@intFromPtr(mapper.directory));
const phys = syscalls.allocFrame() catch {
while (true) {}
};
vm.map(&mapper, 0x6000000, .{ .address = phys }, @intFromEnum(vm.Flags.ReadWrite) | @intFromEnum(vm.Flags.User)) catch {
while (true) {}
};
const event_queue = setupKernelRingBuffer(base) catch { const event_queue = setupKernelRingBuffer(base) catch {
while (true) {} while (true) {}