Move kernel/userland thread handling to platform-independent implementation

This commit is contained in:
Benny Baumann
2021-04-10 14:08:26 +02:00
committed by BenBE
parent 1a1fddae85
commit 7224d0e083
19 changed files with 49 additions and 106 deletions

View File

@ -96,10 +96,6 @@ static int FreeBSDProcess_compareByKey(const Process* v1, const Process* v2, Pro
}
}
bool Process_isThread(const Process* this) {
return Process_isKernelThread(this) || Process_isUserlandThread(this);
}
const ProcessClass FreeBSDProcess_class = {
.super = {
.extends = Class(Process),

View File

@ -16,19 +16,10 @@ in the source distribution for its full text.
typedef struct FreeBSDProcess_ {
Process super;
bool isKernelThread;
int jid;
char* jname;
} FreeBSDProcess;
static inline bool Process_isKernelThread(const Process* this) {
return ((const FreeBSDProcess*)this)->isKernelThread;
}
static inline bool Process_isUserlandThread(const Process* this) {
return this->pid != this->tgid;
}
extern const ProcessClass FreeBSDProcess_class;
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
@ -37,6 +28,4 @@ Process* FreeBSDProcess_new(const Settings* settings);
void Process_delete(Object* cast);
bool Process_isThread(const Process* this);
#endif

View File

@ -456,7 +456,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
if (!preExisting) {
fp->jid = kproc->ki_jid;
proc->pid = kproc->ki_pid;
fp->isKernelThread = kproc->ki_pid != 0 && kproc->ki_pid != 1 && (kproc->ki_flag & P_SYSTEM);
proc->isKernelThread = kproc->ki_pid != 0 && kproc->ki_pid != 1 && (kproc->ki_flag & P_SYSTEM);
proc->isUserlandThread = false;
proc->ppid = kproc->ki_ppid;
proc->tpgid = kproc->ki_tpgid;
proc->tgid = kproc->ki_pid;