mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[tools] Add j6threads gdb command
The j6threads command shows the current thread, ready threads, and blocked threads for a given CPU. To support this, TCB structs gained a pointer to their thread (instead of trying to do offset magic) and threads gained a pointer to their creator. Also removed thread::from_tcb() now that the TCB has a pointer.
This commit is contained in:
@@ -24,12 +24,14 @@ thread::thread(process &parent, uint8_t pri, uintptr_t rsp0) :
|
||||
{
|
||||
parent.space().initialize_tcb(m_tcb);
|
||||
m_tcb.priority = pri;
|
||||
m_tcb.thread = this;
|
||||
|
||||
if (!rsp0)
|
||||
setup_kernel_stack();
|
||||
else
|
||||
m_tcb.rsp0 = rsp0;
|
||||
|
||||
m_creator = current_cpu().thread;
|
||||
m_self_handle = parent.add_handle(this);
|
||||
}
|
||||
|
||||
@@ -38,14 +40,6 @@ thread::~thread()
|
||||
g_kernel_stacks.return_section(m_tcb.kernel_stack);
|
||||
}
|
||||
|
||||
thread *
|
||||
thread::from_tcb(TCB *tcb)
|
||||
{
|
||||
static ptrdiff_t offset =
|
||||
-1 * static_cast<ptrdiff_t>(offsetof(thread, m_tcb));
|
||||
return reinterpret_cast<thread*>(util::offset_pointer(tcb, offset));
|
||||
}
|
||||
|
||||
thread & thread::current() { return *current_cpu().thread; }
|
||||
|
||||
inline void schedule_if_current(thread *t) { if (t == current_cpu().thread) scheduler::get().schedule(); }
|
||||
|
||||
@@ -18,6 +18,9 @@ struct TCB
|
||||
uintptr_t rsp3;
|
||||
uintptr_t rflags3;
|
||||
uintptr_t pml4;
|
||||
// End of area used by asembly
|
||||
|
||||
thread* thread;
|
||||
|
||||
uint8_t priority;
|
||||
// note: 3 bytes padding
|
||||
@@ -46,9 +49,6 @@ public:
|
||||
none = 0x00
|
||||
};
|
||||
|
||||
/// Get the pointer to the thread object containing this TCB
|
||||
static thread * from_tcb(TCB *tcb);
|
||||
|
||||
/// Destructor
|
||||
virtual ~thread();
|
||||
|
||||
@@ -175,6 +175,7 @@ private:
|
||||
tcb_node m_tcb;
|
||||
|
||||
process &m_parent;
|
||||
thread *m_creator;
|
||||
|
||||
state m_state;
|
||||
wait_type m_wait_type;
|
||||
|
||||
Reference in New Issue
Block a user