FreeBSD: simplify kernel thread logic

This commit is contained in:
Christian Göttsche 2021-01-27 15:11:54 +01:00 committed by BenBE
parent 56c4055fd1
commit 399add39ca
3 changed files with 4 additions and 14 deletions

View File

@ -110,13 +110,7 @@ static int FreeBSDProcess_compareByKey(const Process* v1, const Process* v2, Pro
}
bool Process_isThread(const Process* this) {
const FreeBSDProcess* fp = (const FreeBSDProcess*) this;
if (fp->kernel == 1 ) {
return 1;
} else {
return Process_isUserlandThread(this);
}
return Process_isKernelThread(this) || Process_isUserlandThread(this);
}
const ProcessClass FreeBSDProcess_class = {

View File

@ -20,14 +20,14 @@ extern const char* const nodevStr;
typedef struct FreeBSDProcess_ {
Process super;
int kernel;
bool isKernelThread;
int jid;
char* jname;
const char* ttyPath;
} FreeBSDProcess;
static inline bool Process_isKernelThread(const Process* this) {
return ((const FreeBSDProcess*)this)->kernel == 1;
return ((const FreeBSDProcess*)this)->isKernelThread;
}
static inline bool Process_isUserlandThread(const Process* this) {

View File

@ -485,11 +485,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
if (!preExisting) {
fp->jid = kproc->ki_jid;
proc->pid = kproc->ki_pid;
if ( ! ((kproc->ki_pid == 0) || (kproc->ki_pid == 1) ) && kproc->ki_flag & P_SYSTEM) {
fp->kernel = 1;
} else {
fp->kernel = 0;
}
fp->isKernelThread = kproc->ki_pid != 0 && kproc->ki_pid != 1 && (kproc->ki_flag & P_SYSTEM);
proc->ppid = kproc->ki_ppid;
proc->tpgid = kproc->ki_tpgid;
proc->tgid = kproc->ki_pid;