strat: statically allocate additional threads

This commit is contained in:
Michael Scire 2019-10-18 20:31:15 -07:00 committed by SciresM
parent fbb5730369
commit 535e49a38d
17 changed files with 123 additions and 42 deletions

View file

@ -22,8 +22,6 @@
namespace sts::fatal::srv {
class ITask {
public:
static constexpr size_t DefaultStackSize = 0x1000;
protected:
const ThrowContext *context = nullptr;
public:
@ -32,14 +30,30 @@ namespace sts::fatal::srv {
}
virtual Result Run() = 0;
virtual const char *GetName() const = 0;
virtual u8 *GetStack() = 0;
virtual size_t GetStackSize() const = 0;
};
virtual size_t GetStackSize() const {
return DefaultStackSize;
template<size_t _StackSize>
class ITaskWithStack : public ITask {
public:
static constexpr size_t StackSize = _StackSize;
static_assert(util::IsAligned(StackSize, 0x1000), "StackSize alignment");
protected:
alignas(0x1000) u8 stack_mem[StackSize] = {};
public:
virtual u8 *GetStack() override final {
return this->stack_mem;
}
virtual size_t GetStackSize() const override final {
return StackSize;
}
};
using ITaskWithDefaultStack = ITaskWithStack<0x2000>;
void RunTasks(const ThrowContext *ctx);
}