Author: bonefish Date: 2011-05-13 23:10:10 +0200 (Fri, 13 May 2011) New Revision: 41482 Changeset: https://dev.haiku-os.org/changeset/41482 Modified: haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h haiku/branches/developer/bonefish/signals/src/system/kernel/TeamThreadTables.h haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp Log: Added an int64 serial_number field to Thread and Team. It is set when the object is added to the global hash table. Modified: haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h =================================================================== --- haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 2011-05-13 20:52:52 UTC (rev 41481) +++ haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 2011-05-13 21:10:10 UTC (rev 41482) @@ -220,6 +220,8 @@ // child's fLock Team *group_next; // protected by the group's lock + int64 serial_number; // immutable after adding team to hash + // process group info -- write-protected by both the group's lock, the // team's lock, and the team's parent's lock pid_t group_id; @@ -326,11 +328,12 @@ int32 flags; // summary of events relevant in interrupt // handlers (signals pending, user debugging // enabled, etc.) + thread_id id; + int64 serial_number; // immutable after adding thread to hash Thread *hash_next; // protected by thread hash lock Thread *team_next; // protected by team lock and fLock Thread *queue_next; // protected by scheduler lock timer alarm; // protected by scheduler lock - thread_id id; char name[B_OS_NAME_LENGTH]; // protected by fLock int32 priority; // protected by scheduler lock int32 next_priority; // protected by scheduler lock Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/TeamThreadTables.h =================================================================== --- haiku/branches/developer/bonefish/signals/src/system/kernel/TeamThreadTables.h 2011-05-13 20:52:52 UTC (rev 41481) +++ haiku/branches/developer/bonefish/signals/src/system/kernel/TeamThreadTables.h 2011-05-13 21:10:10 UTC (rev 41482) @@ -64,6 +64,12 @@ }; public: + TeamThreadTable() + : + fNextSerialNumber(1) + { + } + status_t Init(size_t initialSize) { return fTable.Init(initialSize); @@ -71,6 +77,7 @@ void Insert(Element* element) { + element->serial_number = fNextSerialNumber++; fTable.InsertUnchecked(element); fList.Add(element); } @@ -161,6 +168,7 @@ private: ElementTable fTable; List fList; + int64 fNextSerialNumber; }; Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp =================================================================== --- haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp 2011-05-13 20:52:52 UTC (rev 41481) +++ haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp 2011-05-13 21:10:10 UTC (rev 41482) @@ -431,6 +431,7 @@ { // allocate an ID id = kernel ? 1 : allocate_thread_id(); + serial_number = -1; // init mutex if (kernel) { @@ -897,6 +898,7 @@ { kprintf("TEAM: %p\n", team); kprintf("id: %ld (%#lx)\n", team->id, team->id); + kprintf("serial_number: %" B_PRId64 "\n", team->serial_number); kprintf("name: '%s'\n", team->Name()); kprintf("args: '%s'\n", team->Args()); kprintf("hash_next: %p\n", team->hash_next); Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp =================================================================== --- haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp 2011-05-13 20:52:52 UTC (rev 41481) +++ haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp 2011-05-13 21:10:10 UTC (rev 41482) @@ -157,10 +157,11 @@ Thread::Thread(const char* name, thread_id threadID, struct cpu_ent* cpu) : flags(0), + id(threadID >= 0 ? threadID : allocate_thread_id()), + serial_number(-1), hash_next(NULL), team_next(NULL), queue_next(NULL), - id(threadID >= 0 ? threadID : allocate_thread_id()), priority(-1), next_priority(-1), io_priority(-1), @@ -1286,6 +1287,7 @@ kprintf("THREAD: %p\n", thread); kprintf("id: %ld (%#lx)\n", thread->id, thread->id); + kprintf("serial_number: %" B_PRId64 "\n", thread->serial_number); kprintf("name: \"%s\"\n", thread->name); kprintf("hash_next: %p\nteam_next: %p\nq_next: %p\n", thread->hash_next, thread->team_next, thread->queue_next);