Set thread affinity. Pin current thread to a particular core * * @param[in] core_id ID of the core to which the current thread is pinned */
| 97 | * @param[in] core_id ID of the core to which the current thread is pinned |
| 98 | */ |
| 99 | void set_thread_affinity(int core_id) |
| 100 | { |
| 101 | if (core_id < 0) |
| 102 | { |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | #if !defined(_WIN64) && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__QNX__) |
| 107 | cpu_set_t set; |
| 108 | CPU_ZERO(&set); |
| 109 | CPU_SET(core_id, &set); |
| 110 | ARM_COMPUTE_EXIT_ON_MSG(sched_setaffinity(0, sizeof(set), &set), "Error setting thread affinity"); |
| 111 | #endif /* !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__QNX__) */ |
| 112 | } |
| 113 | |
| 114 | /** There are currently 2 scheduling modes supported by CPPScheduler |
| 115 | * |
no outgoing calls
no test coverage detected