kernel/thread: move next_thread_id into manager

This commit is contained in:
Weiyi Wang 2018-10-23 10:32:23 -04:00
parent 34f1fe088c
commit 876729ab52
2 changed files with 10 additions and 10 deletions

View file

@ -48,14 +48,7 @@ static Common::ThreadQueueList<Thread*, ThreadPrioLowest + 1> ready_queue;
static SharedPtr<Thread> current_thread; static SharedPtr<Thread> current_thread;
// The first available thread id at startup u32 ThreadManager::NewThreadId() {
static u32 next_thread_id;
/**
* Creates a new thread ID
* @return The new thread ID
*/
inline static u32 const NewThreadId() {
return next_thread_id++; return next_thread_id++;
} }
@ -348,7 +341,7 @@ ResultVal<SharedPtr<Thread>> KernelSystem::CreateThread(std::string name, VAddr
thread_list.push_back(thread); thread_list.push_back(thread);
ready_queue.prepare(priority); ready_queue.prepare(priority);
thread->thread_id = NewThreadId(); thread->thread_id = thread_manager->NewThreadId();
thread->status = ThreadStatus::Dormant; thread->status = ThreadStatus::Dormant;
thread->entry_point = entry_point; thread->entry_point = entry_point;
thread->stack_top = stack_top; thread->stack_top = stack_top;
@ -504,7 +497,6 @@ void ThreadingInit() {
ThreadWakeupEventType = CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback); ThreadWakeupEventType = CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback);
current_thread = nullptr; current_thread = nullptr;
next_thread_id = 1;
} }
void ThreadingShutdown() { void ThreadingShutdown() {

View file

@ -55,6 +55,14 @@ enum class ThreadWakeupReason {
class ThreadManager { class ThreadManager {
public: public:
/**
* Creates a new thread ID
* @return The new thread ID
*/
u32 NewThreadId();
private:
u32 next_thread_id = 1;
}; };
class Thread final : public WaitObject { class Thread final : public WaitObject {