mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user