added new override

This commit is contained in:
user
2026-02-03 19:48:53 +01:00
parent 8cab43f197
commit 467fc6cd0c
2 changed files with 21 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
#include "thread.h" #include "thread.h"
#include "../arch/core_ring.h" #include "../arch/core_ring.h"
#include "../memory/pageframealloc.h"
#include "../debug/kernelpanic.h" #include "../debug/kernelpanic.h"
#include "../interrupt/guard.h" #include "../interrupt/guard.h"
#include "debug/output.h" #include "debug/output.h"
@@ -52,6 +52,17 @@ void Thread::resume(Thread *next) {
context_switch(&next->context, &context); context_switch(&next->context, &context);
} }
void* operator new(std::size_t sz)
{
if (sz == 0)
++sz; // avoid std::malloc(0) which may return nullptr on success
if (void *ptr = PagreFrameAllocator::alloc(true))
return ptr;
}
void Thread::go() { context_launch(&context); } void Thread::go() { context_launch(&context); }
void Thread::action() { kernelpanic("Wrong entry / missing action in Thread"); } void Thread::action() { kernelpanic("Wrong entry / missing action in Thread"); }

View File

@@ -73,6 +73,9 @@ class Thread {
/*! \brief Unique thread id */ /*! \brief Unique thread id */
const size_t id; const size_t id;
/*! \brief Marker for a dying thread /*! \brief Marker for a dying thread
*/ */
volatile bool kill_flag; volatile bool kill_flag;
@@ -110,4 +113,10 @@ class Thread {
* meaningful code to be run in this thread. * meaningful code to be run in this thread.
*/ */
virtual void action() = 0; // XXX: why is this not always pure virtual? virtual void action() = 0; // XXX: why is this not always pure virtual?
//
//
//
void* operator new ( std::size_t count );
}; };