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 {
intptr64_t id;
uintptr64_t sync;
} sync;
struct {
uint32_t nd;
pid_t pid;
int32_t coid;
int32_t chid;
int32_t scoid;
uint32_t flags;
} connect;
struct {
int32_t chid;
} channel;
struct {
pid_t pid;
uint32_t flags;
uintptr64_t vaddr;
} waitpage;
struct {
size64_t size;
} stack;
struct {
pthread_t tid;
} thread_event;
struct {
pid_t child;
} fork_event;
uint64_t filler[4];
} blocked;
As you can see, there are various structures
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
- Contains details about the connection on which the thread is blocked
(used with STATE_SEND and STATE_REPLY).
These details include the node descriptor, process ID, channel ID, client and server connection IDs,
and a flags field with a bit, BLOCKED_CONNECT_FLAGS_SERVERMON, that indicates whether the thread
has requested server monitor services.
- 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),
and the ID of the process whose address space was active when the page fault occurred.
(The flags field is for internal use only.)
- stack
- Used with STATE_STACK, indicates the thread is waiting for size bytes of virtual address space to be made available for the stack.
- thread_event
- If why is _DEBUG_WHY_THREAD, indicates the thread ID of
the created or destroyed thread.
- fork_event
- If why is _DEBUG_WHY_CHILD, indicates the process ID of the child.