start of illumos cpu binding implementation.

The current user needs the proc_owner permission, not something doable
 via the settings script.
This commit is contained in:
David Carlier
2020-06-10 16:16:47 +01:00
parent 5cb6dc7795
commit b3feda052d
4 changed files with 106 additions and 11 deletions

View File

@ -54,7 +54,7 @@
#include "common.h"
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__APPLE__) || defined(__DragonFly__)
defined(__APPLE__) || defined(__DragonFly__) || defined(__sun)
#define HAVE_AFFINITY 1
#if defined(__FreeBSD__) || defined(__DragonFly__)
#include <pthread.h>
@ -70,6 +70,8 @@
#include <pthread.h>
#include <mach/thread_act.h>
#include <mach/thread_policy.h>
#elif defined(__sun)
#include <sys/pset.h>
#endif
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ || __APPLE__ */
@ -181,6 +183,12 @@ int main(int argc, char **argv) {
if (thread_policy_set(native_thread, THREAD_AFFINITY_POLICY,
(thread_policy_t)&c, 1) != KERN_SUCCESS)
PFATAL("thread_policy_set failed");
#elif defined(__sun)
psetid_t c;
if (pset_create(&c)) PFATAL("pset_create failed");
if (pset_assign(c, i, NULL)) PFATAL("pset_assign failed");
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
@ -195,6 +203,13 @@ int main(int argc, char **argv) {
cpuset_destroy(c);
#endif
#if defined(__sun)
if (pset_bind(c, P_PID, getpid(), NULL))
PFATAL("pset_bind failed");
pset_destroy(c);
#endif
#if defined(__linux__)
if (sched_setaffinity(0, sizeof(c), &c)) {