[kernel] Remove thread_data pointer from TCB

The TCB is always stored at a constant offset within the thread object.
So instead of carrying an extra pointer, just implement thread::from_tcb
to get the thread.
This commit is contained in:
2020-07-19 17:01:15 -07:00
parent ef5c333030
commit c3abe035c8
5 changed files with 20 additions and 12 deletions

View File

@@ -16,10 +16,17 @@ thread::thread(process &parent, uint8_t pri) :
TCB *tcbp = tcb();
tcbp->pml4 = parent.pml4();
tcbp->priority = pri;
tcbp->thread_data = this;
set_state(state::ready);
}
thread *
thread::from_tcb(TCB *tcb)
{
static ptrdiff_t offset =
-1 * static_cast<ptrdiff_t>(offsetof(thread, m_tcb));
return reinterpret_cast<thread*>(kutil::offset_pointer(tcb, offset));
}
void
thread::wait_on_signals(kobject *obj, j6_signal_t signals)
{