FS-4220 --resolve i refactored this into a general cross platform function and use it everywhere else we try to set affinity

This commit is contained in:
Anthony Minessale
2012-05-15 08:31:33 -05:00
parent 0d2739bfd2
commit 5c75d4cf5b
5 changed files with 35 additions and 27 deletions

View File

@@ -1325,6 +1325,35 @@ SWITCH_DECLARE(uint32_t) switch_core_min_dtmf_duration(uint32_t duration)
return runtime.min_dtmf_duration;
}
SWITCH_DECLARE(switch_status_t) switch_core_thread_set_cpu_affinity(int cpu)
{
switch_status_t status = SWITCH_STATUS_FALSE;
if (cpu > -1) {
#ifdef HAVE_CPU_SET_MACROS
cpu_set_t set;
CPU_ZERO(&set);
CPU_SET(cpu, &set);
if (!sched_setaffinity(0, sizeof(set), &set)) {
status = SWITCH_STATUS_SUCCESS;
}
#else
#if WIN32
if (SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR) cpu)) {
status = SWITCH_STATUS_SUCCESS;
}
#endif
#endif
}
return status;
}
static void switch_core_set_serial(void)
{
char buf[13] = "";