summaryrefslogtreecommitdiffstats
path: root/AffinityPanel.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2011-09-24 00:30:47 +0000
committerHisham Muhammad <hisham@gobolinux.org>2011-09-24 00:30:47 +0000
commitec17b7029a5f5f2e42d66380762ab24fa5174fc4 (patch)
tree39de052be8fcdbb1a58150eedde74bfbc0d5b92c /AffinityPanel.c
parentd07b043ee07caa5da9e93a5a2ca9165ff98f85d7 (diff)
Convert affinity control from the deprecated PLPA to HWLOC
Diffstat (limited to 'AffinityPanel.c')
-rw-r--r--AffinityPanel.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/AffinityPanel.c b/AffinityPanel.c
index b3ea4123..504638e7 100644
--- a/AffinityPanel.c
+++ b/AffinityPanel.c
@@ -1,9 +1,8 @@
+#include "ProcessList.h"
#include "AffinityPanel.h"
-
#include "Panel.h"
#include "CheckItem.h"
-#include "ProcessList.h"
#include "debug.h"
#include <assert.h>
@@ -26,25 +25,33 @@ static HandlerResult AffinityPanel_eventHandler(Panel* this, int ch) {
return result;
}
-Panel* AffinityPanel_new(ProcessList* pl, unsigned long mask) {
+Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity) {
Panel* this = Panel_new(1, 1, 1, 1, CHECKITEM_CLASS, true, ListItem_compare);
this->eventHandler = AffinityPanel_eventHandler;
Panel_setHeader(this, "Use CPUs:");
+ int curCpu = 0;
for (int i = 0; i < pl->cpuCount; i++) {
char number[10];
snprintf(number, 9, "%d", ProcessList_cpuId(pl, i));
- Panel_add(this, (Object*) CheckItem_new(String_copy(number), NULL, mask & (1 << i)));
+ bool mode;
+ if (curCpu < affinity->used && affinity->cpus[curCpu] == i) {
+ mode = true;
+ curCpu++;
+ } else {
+ mode = false;
+ }
+ Panel_add(this, (Object*) CheckItem_new(String_copy(number), NULL, mode));
}
return this;
}
-unsigned long AffinityPanel_getAffinity(Panel* this) {
+Affinity* AffinityPanel_getAffinity(Panel* this) {
+ Affinity* affinity = Affinity_new();
int size = Panel_size(this);
- unsigned long mask = 0;
for (int i = 0; i < size; i++) {
if (CheckItem_get((CheckItem*)Panel_get(this, i)))
- mask = mask | (1 << i);
+ Affinity_add(affinity, i);
}
- return mask;
+ return affinity;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy