The DCMD_PROC_TIDSTATUS command

Updated: April 19, 2023

The DCMD_PROC_TIDSTATUS command returns a structure of type procfs_status, which is equivalent to debug_thread_t:

typedef struct _debug_thread_info64 {
    pid_t                       pid;
    pthread_t                   tid;
    uint32_t                    flags;
    uint16_t                    why;
    uint16_t                    what;
    uint64_t                    ip;
    uint64_t                    sp;
    uint64_t                    stkbase;
    uint64_t                    tls;
    uint32_t                    stksize;
    uint32_t                    tid_flags;
    uint8_t                     priority;
    uint8_t                     real_priority;
    uint8_t                     policy;
    uint8_t                     state;
    int16_t                     syscall;
    uint16_t                    last_cpu;
    uint32_t                    timeout;
    int32_t                     last_chid;
    sigset_t                    sig_blocked;
    sigset_t                    sig_pending;
    __siginfo32_t                __info32;

    // blocked thread information deleted (see next section)

    uint64_t                    start_time;
    uint64_t                    sutime;
    uint8_t                     extsched[8];
    uint64_t                    nsec_since_block;

    union {
        __siginfo32_t           info32;
        __siginfo64_t           info64;
        siginfo_t               info;
    };

    uint64_t                    reserved2[4];
} debug_thread64_t;

More information than you can shake a stick at! Here are the fields and their meanings:

pid and tid
The process ID and the thread ID.
flags
Flags indicating characteristics of the thread (see <sys/debug.h> and look for the constants beginning with _DEBUG_FLAG_).
why and what
The why indicates why the thread was stopped (see <sys/debug.h> and look for the constants beginning with _DEBUG_WHY_) and the what provides additional information for the why parameter. For _DEBUG_WHY_TERMINATED, the what variable contains the exit code value, for _DEBUG_WHY_SIGNALLED and _DEBUG_WHY_JOBCONTROL, what contains the signal number, and for _DEBUG_WHY_FAULTED, what contains the fault number (see <sys/fault.h> for the values).
ip
The current instruction pointer where this thread is executing.
sp
The current stack pointer for the thread.
stkbase and stksize
The base of the thread's stack, and the stack size.
tls
The Thread Local Storage (TLS) data area. See <sys/storage.h>.
tid_flags
See <sys/neutrino.h> constants beginning with _NTO_TF.
priority and real_priority
The priority indicates thread priority used for scheduling purposes (may be boosted), and the real_priority indicates the actual thread priority (not boosted).
policy
The scheduling policy (e.g. FIFO, Round Robin).
state
The current state of the thread (e.g., STATE_MUTEX if blocked waiting on a mutex; see <sys/states.h>).
syscall
Indicates the last system call that the thread made (see <sys/kercalls.h>).
last_cpu
The last CPU number that the thread ran on (for SMP systems).
timeout
Contains the flags parameter from the last TimerTimeout() call.
last_chid
The last channel ID that this thread MsgReceive()'d on. Used for priority boosting if a client does a MsgSend() and there are no threads in STATE_RECEIVE on the channel.
sig_blocked, sig_pending, and info
These fields all relate to signals—recall that signals have a process aspect as well as a thread aspect. The sig_blocked indicates which signals this thread has blocked. Similarly, sig_pending indicates which signals are pending on this thread. The info member carries the information for a sigwaitinfo() function.
start_time
The time, in nanoseconds since January 1, 1970, that the thread was started. Useful for detecting thread ID reuse.
sutime
Thread's system and user running times (in nanoseconds).
nsec_since_block
How long the thread has been blocked, in nanoseconds, but to millisecond resolution. This is 0 for STATE_READY or STATE_RUNNING.