From 3854cc29ae4ca393abeb58e997b427188d3302a0 Mon Sep 17 00:00:00 2001 From: Avi Kivity <avi@cloudius-systems.com> Date: Tue, 19 Feb 2013 18:04:34 +0200 Subject: [PATCH] sched: add thread ID for debugging --- core/sched.cc | 2 ++ include/sched.hh | 3 +++ 2 files changed, 5 insertions(+) diff --git a/core/sched.cc b/core/sched.cc index 995b30ba6..6b3f36d1d 100644 --- a/core/sched.cc +++ b/core/sched.cc @@ -152,6 +152,7 @@ typedef bi::list<thread, &thread::_thread_list_link> > thread_list_type; thread_list_type thread_list; +unsigned long thread::_s_idgen; thread::thread(std::function<void ()> func, attr attr, bool main) : _func(func) @@ -162,6 +163,7 @@ thread::thread(std::function<void ()> func, attr attr, bool main) { with_lock(thread_list_mutex, [this] { thread_list.push_back(*this); + _id = _s_idgen++; }); setup_tcb(); init_stack(); diff --git a/include/sched.hh b/include/sched.hh index 3187363c7..1330d9e98 100644 --- a/include/sched.hh +++ b/include/sched.hh @@ -154,6 +154,7 @@ public: stack_info get_stack_info(); cpu* tcpu(); void join(); + unsigned long id(); // guaranteed unique over system lifetime private: void main(); void switch_to(); @@ -184,6 +185,7 @@ private: cpu* _cpu; bool _timers_need_reload; bi::list<timer> _active_timers; + unsigned long _id; friend void thread_main_c(thread* t); friend class wait_guard; friend class cpu; @@ -198,6 +200,7 @@ public: lockless_queue_link<thread> _wakeup_link; // for the debugger bi::list_member_hook<> _thread_list_link; + static unsigned long _s_idgen; }; class detached_thread : public thread { -- GitLab