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 {
int32_t id;
uintptr_t sync;
} sync;
struct {
uint32_t nd;
pid_t pid;
int32_t coid;
int32_t chid;
int32_t scoid;
} connect;
struct {
int32_t chid;
} channel;
struct {
pid_t pid;
uintptr_t vaddr;
uint32_t flags;
} waitpage;
struct {
uint32_t 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.