Cleanup Thread constructor

This commit is contained in:
Drew Galbraith 2023-06-06 18:40:32 -07:00
parent 41d25a7b46
commit d9b17d96d7
3 changed files with 3 additions and 4 deletions

View File

@ -27,7 +27,7 @@ Process::Process() : id_(gNextId++), state_(RUNNING) {
} }
SharedPtr<Thread> Process::CreateThread() { SharedPtr<Thread> Process::CreateThread() {
SharedPtr<Thread> thread{new Thread(*this, next_thread_id_++, 0)}; SharedPtr<Thread> thread{new Thread(*this, next_thread_id_++)};
threads_.PushBack(thread); threads_.PushBack(thread);
return thread; return thread;
} }

View File

@ -24,8 +24,7 @@ SharedPtr<Thread> Thread::RootThread(Process& root_proc) {
return new Thread(root_proc); return new Thread(root_proc);
} }
Thread::Thread(Process& proc, uint64_t tid, uint64_t entry) Thread::Thread(Process& proc, uint64_t tid) : process_(proc), id_(tid) {
: process_(proc), id_(tid), rip_(entry) {
uint64_t* stack_ptr = proc.vmm().AllocateKernelStack(); uint64_t* stack_ptr = proc.vmm().AllocateKernelStack();
// 0: rip // 0: rip
*(stack_ptr) = reinterpret_cast<uint64_t>(thread_init); *(stack_ptr) = reinterpret_cast<uint64_t>(thread_init);

View File

@ -18,7 +18,7 @@ class Thread {
}; };
static SharedPtr<Thread> RootThread(Process& root_proc); static SharedPtr<Thread> RootThread(Process& root_proc);
Thread(Process& proc, uint64_t tid, uint64_t entry); Thread(Process& proc, uint64_t tid);
uint64_t tid() const { return id_; }; uint64_t tid() const { return id_; };
uint64_t pid() const; uint64_t pid() const;