diff options
author | Benny Baumann <BenBE@geshi.org> | 2021-04-10 14:08:26 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-05-23 09:22:21 +0200 |
commit | 7224d0e0831ee53d5028915f87dffd51ffa0d6fa (patch) | |
tree | c193e41f03dd30cf414d427c5e4e71b127842d98 /solaris | |
parent | 1a1fddae851b344b0a89a8f2753e2d2487f34064 (diff) |
Move kernel/userland thread handling to platform-independent implementation
Diffstat (limited to 'solaris')
-rw-r--r-- | solaris/SolarisProcess.c | 12 | ||||
-rw-r--r-- | solaris/SolarisProcess.h | 8 | ||||
-rw-r--r-- | solaris/SolarisProcessList.c | 20 |
3 files changed, 11 insertions, 29 deletions
diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c index 7b82f90f..688d98ca 100644 --- a/solaris/SolarisProcess.c +++ b/solaris/SolarisProcess.c @@ -121,18 +121,6 @@ static int SolarisProcess_compareByKey(const Process* v1, const Process* v2, Pro } } -bool Process_isThread(const Process* this) { - const SolarisProcess* fp = (const SolarisProcess*) this; - - if (fp->kernel == 1 ) { - return 1; - } else if (fp->is_lwp) { - return 1; - } else { - return 0; - } -} - const ProcessClass SolarisProcess_class = { .super = { .extends = Class(Process), diff --git a/solaris/SolarisProcess.h b/solaris/SolarisProcess.h index 07b889c0..0fd458dc 100644 --- a/solaris/SolarisProcess.h +++ b/solaris/SolarisProcess.h @@ -26,24 +26,18 @@ in the source distribution for its full text. typedef struct SolarisProcess_ { Process super; - int kernel; zoneid_t zoneid; char* zname; taskid_t taskid; projid_t projid; poolid_t poolid; ctid_t contid; - bool is_lwp; pid_t realpid; pid_t realppid; pid_t realtgid; pid_t lwpid; } SolarisProcess; -#define Process_isKernelThread(_process) (_process->kernel == 1) - -#define Process_isUserlandThread(_process) (_process->pid != _process->tgid) - extern const ProcessClass SolarisProcess_class; extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; @@ -52,6 +46,4 @@ Process* SolarisProcess_new(const Settings* settings); void Process_delete(Object* cast); -bool Process_isThread(const Process* this); - #endif diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index fd1d5a2f..93561fa3 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -322,6 +322,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, } else { getpid = lwpid; } + Process* proc = ProcessList_getProcess(pl, getpid, &preExisting, SolarisProcess_new); SolarisProcess* sproc = (SolarisProcess*) proc; @@ -376,18 +377,18 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, proc->percent_cpu = ((uint16_t)_psinfo->pr_pctcpu / (double)32768) * (double)100.0; proc->time = _psinfo->pr_time.tv_sec; if (!preExisting) { // Tasks done only for NEW processes - sproc->is_lwp = false; + proc->isUserlandThread = false; proc->starttime_ctime = _psinfo->pr_start.tv_sec; } // Update proc and thread counts based on settings - if (sproc->kernel && !pl->settings->hideKernelThreads) { + if (proc->isKernelThread && !pl->settings->hideKernelThreads) { pl->kernelThreads += proc->nlwp; pl->totalTasks += proc->nlwp + 1; if (proc->state == 'O') { pl->runningTasks++; } - } else if (!sproc->kernel) { + } else if (!proc->isKernelThread) { if (proc->state == 'O') { pl->runningTasks++; } @@ -398,12 +399,12 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, pl->totalTasks += proc->nlwp + 1; } } - proc->show = !(pl->settings->hideKernelThreads && sproc->kernel); + proc->show = !(pl->settings->hideKernelThreads && proc->isKernelThread); } else { // We are not in the master LWP, so jump to the LWP handling code proc->percent_cpu = ((uint16_t)_lwpsinfo->pr_pctcpu / (double)32768) * (double)100.0; proc->time = _lwpsinfo->pr_time.tv_sec; if (!preExisting) { // Tasks done only for NEW LWPs - sproc->is_lwp = true; + proc->isUserlandThread = true; proc->cmdlineBasenameEnd = -1; proc->ppid = _psinfo->pr_pid * 1024; proc->tgid = _psinfo->pr_pid * 1024; @@ -413,10 +414,10 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, } // Top-level process only gets this for the representative LWP - if (sproc->kernel && !pl->settings->hideKernelThreads) { + if (proc->isKernelThread && !pl->settings->hideKernelThreads) { proc->show = true; } - if (!sproc->kernel && !pl->settings->hideUserlandThreads) { + if (!proc->isKernelThread && !pl->settings->hideUserlandThreads) { proc->show = true; } } // Top-level LWP or subordinate LWP @@ -425,10 +426,11 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, if (!preExisting) { if ((sproc->realppid <= 0) && !(sproc->realpid <= 1)) { - sproc->kernel = true; + proc->isKernelThread = true; } else { - sproc->kernel = false; + proc->isKernelThread = false; } + Process_fillStarttimeBuffer(proc); ProcessList_add(pl, proc); } |