mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Move kernel/userland thread handling to platform-independent implementation
This commit is contained in:
@ -94,16 +94,6 @@ static int DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2
|
||||
}
|
||||
}
|
||||
|
||||
bool Process_isThread(const Process* this) {
|
||||
const DragonFlyBSDProcess* fp = (const DragonFlyBSDProcess*) this;
|
||||
|
||||
if (fp->kernel == 1 ) {
|
||||
return 1;
|
||||
} else {
|
||||
return (Process_isUserlandThread(this));
|
||||
}
|
||||
}
|
||||
|
||||
const ProcessClass DragonFlyBSDProcess_class = {
|
||||
.super = {
|
||||
.extends = Class(Process),
|
||||
|
@ -17,16 +17,10 @@ in the source distribution for its full text.
|
||||
|
||||
typedef struct DragonFlyBSDProcess_ {
|
||||
Process super;
|
||||
int kernel;
|
||||
int jid;
|
||||
char* jname;
|
||||
} DragonFlyBSDProcess;
|
||||
|
||||
#define Process_isKernelThread(_process) (_process->kernel == 1)
|
||||
|
||||
//#define Process_isUserlandThread(_process) (_process->pid != _process->tgid)
|
||||
#define Process_isUserlandThread(_process) (_process->nlwp > 1)
|
||||
|
||||
extern const ProcessClass DragonFlyBSDProcess_class;
|
||||
|
||||
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
@ -35,6 +29,4 @@ Process* DragonFlyBSDProcess_new(const Settings* settings);
|
||||
|
||||
void Process_delete(Object* cast);
|
||||
|
||||
bool Process_isThread(const Process* this);
|
||||
|
||||
#endif
|
||||
|
@ -390,12 +390,13 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||
if (kproc->kp_ktaddr && kproc->kp_flags & P_SYSTEM) {
|
||||
// dfb kernel threads all have the same pid, so we misuse the kernel thread address to give them a unique identifier
|
||||
proc->pid = (pid_t)kproc->kp_ktaddr;
|
||||
dfp->kernel = 1;
|
||||
proc->isKernelThread = true;
|
||||
} else {
|
||||
proc->pid = kproc->kp_pid; // process ID
|
||||
dfp->kernel = 0;
|
||||
proc->isKernelThread = false;
|
||||
}
|
||||
proc->ppid = kproc->kp_ppid; // parent process id
|
||||
proc->isUserlandThread = kproc->kp_nthreads > 1;
|
||||
proc->ppid = kproc->kp_ppid; // parent process id
|
||||
proc->tpgid = kproc->kp_tpgid; // tty process group id
|
||||
//proc->tgid = kproc->kp_lwp.kl_tid; // thread group id
|
||||
proc->tgid = kproc->kp_pid; // thread group id
|
||||
|
Reference in New Issue
Block a user