From: Nadav Har'El <[email protected]>
Committer: Nadav Har'El <[email protected]>
Branch: master
libc: pthread_setaffinity_np() on other threads
Previously, pthread_setaffinity_np() only supported working on the current
thread. With this patch we use the new sched::thread::pin(thread*, cpu*)
to support pinning of other threads as well.
Fixes #520.
Signed-off-by: Nadav Har'El <[email protected]>
Message-Id: <[email protected]>
---
diff --git a/libc/pthread.cc b/libc/pthread.cc
--- a/libc/pthread.cc
+++ b/libc/pthread.cc
@@ -943,10 +943,7 @@ int pthread_attr_setaffinity_np(pthread_attr_t *attr,
size_t cpusetsize,
int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize,
const cpu_set_t *cpuset)
{
- if (thread != pthread_self()) {
- WARN_STUBBED();
- return EINVAL;
- }
+ sched::thread *t = &pthread::from_libc(thread)->_thread;
int count = CPU_COUNT(cpuset);
if (count == 0) {
// Having a cpuset with no CPUs in it is invalid.
@@ -955,7 +952,7 @@ int pthread_setaffinity_np(pthread_t thread, size_t
cpusetsize,
for (size_t i = 0; i < __CPU_SETSIZE; i++) {
if (CPU_ISSET(i, cpuset)) {
if (i < sched::cpus.size()) {
- sched::thread::pin(sched::cpus[i]);
+ sched::thread::pin(t, sched::cpus[i]);
break;
} else {
return EINVAL;
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.