1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

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.
This commit is contained in:
Andreas Kling 2019-12-22 11:51:24 +01:00
parent 16812f0f98
commit 4b8851bd01
3 changed files with 14 additions and 2 deletions

View file

@ -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();