We can now change threads

This commit is contained in:
wheremyfoodat 2022-09-20 15:30:41 +03:00
parent 1678cd6172
commit 9b95bd87f1
10 changed files with 159 additions and 14 deletions

View file

@ -6,6 +6,7 @@
#include "kernel_types.hpp"
#include "helpers.hpp"
#include "memory.hpp"
#include "resource_limits.hpp"
#include "services/service_manager.hpp"
class CPU;
@ -17,12 +18,13 @@ class Kernel {
// The handle number for the next kernel object to be created
u32 handleCounter;
std::array<Thread, appResourceLimits.maxThreads> threads;
std::vector<KernelObject> objects;
std::vector<Handle> portHandles;
Handle currentProcess;
Handle currentThread;
Handle mainThread;
int currentThreadIndex;
Handle srvHandle; // Handle for the special service manager port "srv:"
u32 arbiterCount;
u32 threadCount;
@ -64,6 +66,8 @@ class Kernel {
Handle makeSession(Handle port);
Handle makeThread(u32 entrypoint, u32 initialSP, u32 priority, u32 id, ThreadStatus status = ThreadStatus::Dormant);
void switchThread(int newThreadIndex);
std::optional<Handle> getPortHandle(const char* name);
void deleteObjectData(KernelObject& object);