diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-11-18 06:08:56 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-11-18 06:08:56 +0000 |
commit | 7ca10817122d3b7b30fabb1cadb75e5ee14b364e (patch) | |
tree | 14fa282dcad8eac9401fa463484b0b1693f43e1f /Process.c | |
parent | 38856488815711138aa9d0ba32cca66694717171 (diff) |
Mega-commit with features and tweaks for 1.0:
* Performance improvements
* Support for splitting CPU meters into two or four columns
(thanks to Wim Heirman)
* Switch from PLPA, which is now deprecated, to HWLOC.
* Bring back support for native Linux sched_setaffinity,
so we don't have to use HWLOC where we don't need to.
* Support for typing in user names and column fields in selection panels.
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -567,6 +567,7 @@ bool Process_setPriority(Process* this, int priority) { } #ifdef HAVE_HWLOC + Affinity* Process_getAffinity(Process* this) { hwloc_cpuset_t cpuset = hwloc_bitmap_alloc(); bool ok = (hwloc_linux_get_tid_cpubind(this->pl->topology, this->pid, cpuset) == 0); @@ -597,6 +598,31 @@ bool Process_setAffinity(Process* this, Affinity* affinity) { hwloc_bitmap_free(cpuset); return ok; } + +#elif HAVE_NATIVE_AFFINITY + +Affinity* Process_getAffinity(Process* this) { + cpu_set_t cpuset; + bool ok = (sched_getaffinity(this->pid, sizeof(cpu_set_t), &cpuset) == 0); + if (!ok) return NULL; + Affinity* affinity = Affinity_new(); + for (int i = 0; i < this->pl->cpuCount; i++) { + if (CPU_ISSET(i, &cpuset)) + Affinity_add(affinity, i); + } + return affinity; +} + +bool Process_setAffinity(Process* this, Affinity* affinity) { + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + for (int i = 0; i < affinity->used; i++) { + CPU_SET(affinity->cpus[i], &cpuset); + } + bool ok = (sched_setaffinity(this->pid, sizeof(unsigned long), &cpuset) == 0); + return ok; +} + #endif void Process_sendSignal(Process* this, int sgn) { |