mirror of https://github.com/xzeldon/htop.git
Add ProcessList_isCPUonline
This commit is contained in:
parent
41af31be7f
commit
11d2206f40
|
@ -384,7 +384,9 @@ Panel* AffinityPanel_new(ProcessList* pl, const Affinity* affinity, int* width)
|
||||||
|
|
||||||
unsigned int curCpu = 0;
|
unsigned int curCpu = 0;
|
||||||
for (unsigned int i = 0; i < pl->existingCPUs; i++) {
|
for (unsigned int i = 0; i < pl->existingCPUs; i++) {
|
||||||
/* TODO: skip offline CPUs */
|
if (!ProcessList_isCPUonline(this->pl, i))
|
||||||
|
continue;
|
||||||
|
|
||||||
char number[16];
|
char number[16];
|
||||||
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
|
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
|
||||||
unsigned cpu_width = 4 + strlen(number);
|
unsigned cpu_width = 4 + strlen(number);
|
||||||
|
@ -428,8 +430,7 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
|
||||||
Affinity_add(affinity, i);
|
Affinity_add(affinity, i);
|
||||||
hwloc_bitmap_foreach_end();
|
hwloc_bitmap_foreach_end();
|
||||||
#else
|
#else
|
||||||
for (unsigned int i = 0; i < this->pl->existingCPUs; i++) {
|
for (int i = 0; i < Vector_size(this->cpuids); i++) {
|
||||||
/* TODO: skip offline CPUs */
|
|
||||||
const MaskItem* item = (const MaskItem*)Vector_get(this->cpuids, i);
|
const MaskItem* item = (const MaskItem*)Vector_get(this->cpuids, i);
|
||||||
if (item->value) {
|
if (item->value) {
|
||||||
Affinity_add(affinity, item->cpu);
|
Affinity_add(affinity, item->cpu);
|
||||||
|
|
|
@ -87,9 +87,11 @@ typedef struct ProcessList_ {
|
||||||
unsigned int existingCPUs;
|
unsigned int existingCPUs;
|
||||||
} ProcessList;
|
} ProcessList;
|
||||||
|
|
||||||
|
/* Implemented by platforms */
|
||||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* pidMatchList, uid_t userId);
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* pidMatchList, uid_t userId);
|
||||||
void ProcessList_delete(ProcessList* pl);
|
void ProcessList_delete(ProcessList* pl);
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
|
|
||||||
ProcessList* ProcessList_init(ProcessList* this, const ObjectClass* klass, UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* pidMatchList, uid_t userId);
|
ProcessList* ProcessList_init(ProcessList* this, const ObjectClass* klass, UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* pidMatchList, uid_t userId);
|
||||||
|
|
|
@ -236,3 +236,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
|
|
||||||
free(ps);
|
free(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
// TODO: support offline CPUs and hot swapping
|
||||||
|
(void) super; (void) id;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -34,4 +34,6 @@ void ProcessList_delete(ProcessList* this);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -601,3 +601,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
proc->updated = true;
|
proc->updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
// TODO: support offline CPUs and hot swapping
|
||||||
|
(void) super; (void) id;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -59,4 +59,6 @@ void ProcessList_delete(ProcessList* this);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -599,3 +599,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
proc->updated = true;
|
proc->updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
// TODO: support offline CPUs and hot swapping
|
||||||
|
(void) super; (void) id;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -53,4 +53,6 @@ void ProcessList_delete(ProcessList* this);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2081,3 +2081,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
|
|
||||||
LinuxProcessList_recurseProcTree(this, rootFd, PROCDIR, NULL, period);
|
LinuxProcessList_recurseProcTree(this, rootFd, PROCDIR, NULL, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
const LinuxProcessList* this = (const LinuxProcessList*) super;
|
||||||
|
return this->cpuData[id + 1].online;
|
||||||
|
}
|
||||||
|
|
|
@ -120,4 +120,6 @@ void ProcessList_delete(ProcessList* pl);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -447,3 +447,16 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
|
|
||||||
OpenBSDProcessList_scanProcs(opl);
|
OpenBSDProcessList_scanProcs(opl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
const OpenBSDProcessList* opl = (const OpenBSDProcessList*) super;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < super->activeCPUs; i++) {
|
||||||
|
if (opl->cpus[i].cpuIndex == id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -55,4 +55,6 @@ void ProcessList_delete(ProcessList* this);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -675,3 +675,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
double period = (this->timestamp - sample) * 100;
|
double period = (this->timestamp - sample) * 100;
|
||||||
PCPProcessList_updateProcesses(this, period, ×tamp);
|
PCPProcessList_updateProcesses(this, period, ×tamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
// TODO: support offline CPUs and hot swapping
|
||||||
|
(void) super; (void) id;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -69,4 +69,6 @@ void ProcessList_delete(ProcessList* pl);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -495,3 +495,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
super->kernelThreads = 1;
|
super->kernelThreads = 1;
|
||||||
proc_walk(&SolarisProcessList_walkproc, super, PR_WALK_LWP);
|
proc_walk(&SolarisProcessList_walkproc, super, PR_WALK_LWP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
// TODO: support offline CPUs and hot swapping
|
||||||
|
(void) super; (void) id;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -59,4 +59,6 @@ void ProcessList_delete(ProcessList* pl);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -89,3 +89,11 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
if (!preExisting)
|
if (!preExisting)
|
||||||
ProcessList_add(super, proc);
|
ProcessList_add(super, proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
|
||||||
|
assert(id < super->existingCPUs);
|
||||||
|
|
||||||
|
(void) super; (void) id;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -16,4 +16,6 @@ void ProcessList_delete(ProcessList* this);
|
||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
|
||||||
|
|
||||||
|
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue