added new override
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "thread.h"
|
||||
#include "../arch/core_ring.h"
|
||||
|
||||
#include "../memory/pageframealloc.h"
|
||||
#include "../debug/kernelpanic.h"
|
||||
#include "../interrupt/guard.h"
|
||||
#include "debug/output.h"
|
||||
@@ -52,6 +52,17 @@ void Thread::resume(Thread *next) {
|
||||
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::action() { kernelpanic("Wrong entry / missing action in Thread"); }
|
||||
|
||||
@@ -73,6 +73,9 @@ class Thread {
|
||||
/*! \brief Unique thread id */
|
||||
const size_t id;
|
||||
|
||||
|
||||
|
||||
|
||||
/*! \brief Marker for a dying thread
|
||||
*/
|
||||
volatile bool kill_flag;
|
||||
@@ -110,4 +113,10 @@ class Thread {
|
||||
* meaningful code to be run in this thread.
|
||||
*/
|
||||
virtual void action() = 0; // XXX: why is this not always pure virtual?
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
void* operator new ( std::size_t count );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user