struct thread {
// Entry in the list of threads of the containing process
list_node process_entry;
// Entry in this thread's scheduling queue
list_node sched_entry;
// ...
};
Each struct thread is linked in two lists. When we need to get from a list_node * to the enclosing struct thread, we know from the context which list is being inspected, so we know which one of process_entry or sched_entry to consider for offsetting the pointer.
Comments
Like this:
Each struct thread is linked in two lists. When we need to get from a list_node * to the enclosing struct thread, we know from the context which list is being inspected, so we know which one of process_entry or sched_entry to consider for offsetting the pointer.