kernel/thread: add ThreadManager
This commit is contained in:
parent
f3ee5feb02
commit
34f1fe088c
|
@ -21,6 +21,7 @@ KernelSystem::KernelSystem(u32 system_mode) {
|
|||
Kernel::MemoryInit(system_mode);
|
||||
|
||||
resource_limits = std::make_unique<ResourceLimitList>(*this);
|
||||
thread_manager = std::make_unique<ThreadManager>();
|
||||
Kernel::ThreadingInit();
|
||||
Kernel::TimersInit();
|
||||
}
|
||||
|
@ -53,4 +54,12 @@ void KernelSystem::SetCurrentProcess(SharedPtr<Process> process) {
|
|||
current_process = std::move(process);
|
||||
}
|
||||
|
||||
ThreadManager& KernelSystem::GetThreadManager() {
|
||||
return *thread_manager;
|
||||
}
|
||||
|
||||
const ThreadManager& KernelSystem::GetThreadManager() const {
|
||||
return *thread_manager;
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -28,6 +28,7 @@ class ClientSession;
|
|||
class ServerSession;
|
||||
class ResourceLimitList;
|
||||
class SharedMemory;
|
||||
class ThreadManager;
|
||||
|
||||
enum class ResetType {
|
||||
OneShot,
|
||||
|
@ -187,6 +188,9 @@ public:
|
|||
SharedPtr<Process> GetCurrentProcess() const;
|
||||
void SetCurrentProcess(SharedPtr<Process> process);
|
||||
|
||||
ThreadManager& GetThreadManager();
|
||||
const ThreadManager& GetThreadManager() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ResourceLimitList> resource_limits;
|
||||
std::atomic<u32> next_object_id{0};
|
||||
|
@ -199,6 +203,8 @@ private:
|
|||
std::vector<SharedPtr<Process>> process_list;
|
||||
|
||||
SharedPtr<Process> current_process;
|
||||
|
||||
std::unique_ptr<ThreadManager> thread_manager;
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -59,7 +59,9 @@ inline static u32 const NewThreadId() {
|
|||
return next_thread_id++;
|
||||
}
|
||||
|
||||
Thread::Thread(KernelSystem& kernel) : WaitObject(kernel), context(Core::CPU().NewContext()) {}
|
||||
Thread::Thread(KernelSystem& kernel)
|
||||
: WaitObject(kernel), context(Core::CPU().NewContext()),
|
||||
thread_manager(kernel.GetThreadManager()) {}
|
||||
Thread::~Thread() {}
|
||||
|
||||
Thread* GetCurrentThread() {
|
||||
|
|
|
@ -53,6 +53,10 @@ enum class ThreadWakeupReason {
|
|||
Timeout // The thread was woken up due to a wait timeout.
|
||||
};
|
||||
|
||||
class ThreadManager {
|
||||
public:
|
||||
};
|
||||
|
||||
class Thread final : public WaitObject {
|
||||
public:
|
||||
std::string GetName() const override {
|
||||
|
@ -210,6 +214,8 @@ private:
|
|||
explicit Thread(KernelSystem&);
|
||||
~Thread() override;
|
||||
|
||||
ThreadManager& thread_manager;
|
||||
|
||||
friend class KernelSystem;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue