When a thread is blocked, there's an additional set of fields
that are important (they are within the debug_thread_t, above,
where the comment says "blocking information deleted").
The deleted content is:
union {
struct {
pthread_t tid;
} join;
struct {
_Int32t id;
_Uintptrt sync;
} sync;
struct {
_Uint32t nd;
pid_t pid;
_Int32t coid;
_Int32t chid;
_Int32t scoid;
} connect;
struct {
_Int32t chid;
} channel;
struct {
pid_t pid;
_Uintptrt vaddr;
_Uint32t flags;
} waitpage;
struct {
_Uint32t size;
} stack;
} blocked;
As you can see, there are six major structures (join, sync, connect, channel, waitpage, and stack)
that are unioned together (because a thread can be in only one given blocking state at a time):
- join
- When a thread is in STATE_JOIN, it's waiting to synchronize to the termination
of another thread (in the same process).
This thread is waiting for the termination of the thread identified by the tid member.
- sync
- When a thread is blocked on a synchronization object (such as a mutex, condition variable, or semaphore),
the id member indicates the virtual address of the object, and the sync member indicates the type of object.
- connect
- Indicates who the thread is blocked on (used with STATE_SEND and STATE_REPLY).
- channel
- Indicates the channel ID the thread is blocked in (used with STATE_RECEIVE).
- waitpage
- Indicates the virtual address that the thread is waiting for to be lazy-mapped in (used with STATE_WAITPAGE).
- stack
- Used with STATE_STACK, indicates the thread is waiting for size bytes of virtual address space to be made available for the stack.