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