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]> --- libc/pthread.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libc/pthread.cc b/libc/pthread.cc index 308b220..4c7979e 100644 --- a/libc/pthread.cc +++ b/libc/pthread.cc @@ -941,10 +941,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. @@ -953,7 +950,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; -- 2.5.5 -- 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.
