diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-22 11:51:24 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-22 12:38:01 +0100 |
commit | 4b8851bd01c7e78f44754aa288122b75e9e37485 (patch) | |
tree | b72912689a75041ae4491d38c5480fb910feda10 /Kernel/Thread.cpp | |
parent | 16812f0f9832769330e41421f9057b0b5a8b7b61 (diff) | |
download | serenity-4b8851bd01c7e78f44754aa288122b75e9e37485.zip |
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.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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*>& 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(); |