Task scheduler

This commit is contained in:
2026-02-26 21:08:06 +00:00
parent 6658e4314b
commit d449150169
9 changed files with 836 additions and 62 deletions

View File

@@ -4,6 +4,7 @@
#include "commands.h"
#include "idt.h"
#include "memory.h"
#include "task.h"
#define SAFE_PRINT(Boot, ...) \
do { \
@@ -38,6 +39,7 @@ void kmain(BootInfo *Boot)
idt_init(Boot);
memory_init(Boot);
task_init(Boot);
SAFE_PRINT(Boot, L"================================================\n\r");
SAFE_PRINT(Boot, L" Welcome to Simple UEFI Operating System!\n\r");
@@ -74,12 +76,20 @@ void kmain(BootInfo *Boot)
SAFE_PRINT(Boot, L"-> ");
while (TRUE) {
if (Boot->read_key == NULL) {
/* Try non-blocking read first; yield to other tasks while idle */
if (Boot->try_read_key != NULL) {
Status = Boot->try_read_key(&Key);
if (Status == EFI_NOT_READY) {
task_yield();
continue;
}
} else if (Boot->read_key != NULL) {
Status = Boot->read_key(&Key);
} else {
SAFE_PRINT(Boot, L"Console input unavailable.\n\r");
break;
}
Status = Boot->read_key(&Key);
if (EFI_ERROR(Status)) {
read_errors++;
if (read_errors == 1 || (read_errors % 64) == 0) {