Now that the other CPUs have been brought up, add support for scheduling tasks on them. The scheduler now maintains separate ready/blocked lists per CPU, and CPUs will attempt to balance load via periodic work stealing. Other changes as a result of this: - The device manager no longer creates a local APIC object, but instead just gathers relevant info from the APCI tables. Each CPU creates its own local APIC object. This also spurred the APIC timer calibration to become a static value, as all APICs are assumed to be symmetrical. - Fixed a bug where the scheduler was popping the current task off of its ready list, however the current task is never on the ready list (except the idle task was first set up as both current and ready). This was causing the lists to get into bad states. Now a task can only ever be current or in a ready or blocked list. - Got rid of the unused static process::s_processes list of all processes, instead of trying to synchronize it via locks. - Added spinlocks for synchronization to the scheduler and logger objects.
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#include <stddef.h>
|
|
|
|
#include "kutil/memory.h"
|
|
|
|
#include "console.h"
|
|
#include "debug.h"
|
|
#include "log.h"
|
|
#include "syscall.h"
|
|
|
|
extern "C" {
|
|
void syscall_invalid(uint64_t call);
|
|
}
|
|
|
|
uintptr_t syscall_registry[256] __attribute__((section(".syscall_registry")));
|
|
const char * syscall_names[256] __attribute__((section(".syscall_registry")));
|
|
static constexpr size_t num_syscalls = sizeof(syscall_registry) / sizeof(syscall_registry[0]);
|
|
|
|
void
|
|
syscall_invalid(uint64_t call)
|
|
{
|
|
console *cons = console::get();
|
|
cons->set_color(9);
|
|
cons->printf("\nReceived unknown syscall: %02x\n", call);
|
|
|
|
cons->printf(" Known syscalls:\n");
|
|
cons->printf(" invalid %016lx\n", syscall_invalid);
|
|
|
|
for (unsigned i = 0; i < num_syscalls; ++i) {
|
|
const char *name = syscall_names[i];
|
|
uintptr_t handler = syscall_registry[i];
|
|
if (name)
|
|
cons->printf(" %02x %10s %016lx\n", i, name, handler);
|
|
}
|
|
|
|
cons->set_color();
|
|
_halt();
|
|
}
|
|
|
|
void
|
|
syscall_initialize()
|
|
{
|
|
kutil::memset(&syscall_registry, 0, sizeof(syscall_registry));
|
|
kutil::memset(&syscall_names, 0, sizeof(syscall_names));
|
|
|
|
#define SYSCALL(id, name, result, ...) \
|
|
syscall_registry[id] = reinterpret_cast<uintptr_t>(syscalls::name); \
|
|
syscall_names[id] = #name; \
|
|
log::debug(logs::syscall, "Enabling syscall 0x%02x as " #name , id);
|
|
#include "j6/tables/syscalls.inc"
|
|
#undef SYSCALL
|
|
}
|
|
|