From 4b8851bd01c7e78f44754aa288122b75e9e37485 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 22 Dec 2019 11:51:24 +0100 Subject: Kernel: Make TID's be unique PID's This is a little strange, but it's how I understand things should work. The first thread in a new process now has TID == PID. Additional threads subsequently spawned in that process all have unique TID's generated by the PID allocator. TIDs are now globally unique. --- Kernel/Thread.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Kernel/Thread.cpp') diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 843ecc18ac..c3d62b13c7 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -43,9 +43,14 @@ HashTable& thread_table() Thread::Thread(Process& process) : m_process(process) - , m_tid(process.m_next_tid++) , m_name(process.name()) { + if (m_process.m_thread_count == 0) { + // First thread gets TID == PID + m_tid = process.pid(); + } else { + m_tid = Process::allocate_pid(); + } process.m_thread_count++; dbgprintf("Thread{%p}: New thread TID=%u in %s(%u)\n", this, m_tid, process.name().characters(), process.pid()); set_default_signal_dispositions(); -- cgit v1.2.3