Kernel: Show current_task's name in the log

This commit is contained in:
apio 2022-10-18 18:41:17 +02:00
parent f1bfa6bec8
commit 59506b8852
2 changed files with 10 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#include "io/Serial.h"
#include "std/stdio.h"
#include "thread/PIT.h"
#include "thread/Scheduler.h"
#include <stdarg.h>
static int level_mask = 15;
@ -22,7 +23,13 @@ static void log_backend_serial(const char* function, LogLevel level, const char*
va_list ap;
va_copy(ap, origin);
Serial::reset_color();
printf("[%ld.%ld] %s: ", PIT::ms_since_boot / 1000, PIT::ms_since_boot % 1000, function);
if (Scheduler::current_task() && Scheduler::current_task()->id)
{
Task* current_task = Scheduler::current_task();
printf("[%ld.%ld] (%s %ld) %s: ", PIT::ms_since_boot / 1000, PIT::ms_since_boot % 1000, current_task->name,
current_task->id, function);
}
else { printf("[%ld.%ld] (kernel) %s: ", PIT::ms_since_boot / 1000, PIT::ms_since_boot % 1000, function); }
switch (level)
{
case LogLevel::WARN: Serial::set_color(Color::Yellow); break;

View File

@ -91,6 +91,8 @@ void Scheduler::init()
idle_task.user_task = false;
idle_task.state = idle_task.Idle;
strlcpy(idle_task.name, "[cpu-idle]", sizeof(idle_task.name));
sched_current_task = &idle_task;
frequency = 1000 / PIT::frequency();