59 #include <mach/thread_act.h>
63 thread_affinity_policy_data_t policy = {core};
64 thread_port_t mach_thread = pthread_mach_thread_np(thr);
65 kern_return_t ret = thread_policy_set(mach_thread, THREAD_AFFINITY_POLICY,
66 (thread_policy_t) &policy, 1);
67 return -(ret != KERN_SUCCESS);
76 CPU_SET(core, &cpuset);
77 return -(pthread_setaffinity_np(thr,
sizeof(cpuset), &cpuset) != 0);
84 long ret = sysconf(_SC_NPROCESSORS_ONLN);
85 return ret < 1 ? 1 : (unsigned)ret;
90 return -(pthread_create(thr_p, NULL, t_fnc, t_fnc_arg) != 0);
95 return -(pthread_join(thr, ret) != 0);
101 #define WIN32_LEAN_AND_MEAN
103 #define _WIN32_WINNT _WIN32_WINNT_NT4
109 SYSTEM_INFO sys_info;
110 GetSystemInfo(&sys_info);
111 return sys_info.dwNumberOfProcessors;
116 *thr_p = CreateThread(NULL, 0, t_fnc, arg, 0, NULL);
117 return -(*thr_p == NULL);
122 return -(SetThreadAffinityMask(thr, 1 << core) != 0);
127 if (WaitForSingleObject(thr, INFINITE) == WAIT_FAILED)
131 return -(GetExitCodeThread(thr, ret) == 0);