kernel: introduce convinience apu to pin thread to a cpu
Add an API that clears cpu mask from a thread and sets it to a specific
CPU.
This is the equivelent of:
k_thread_cpu_mask_clear(&thread);
k_thread_cpu_mask_enable(&thread, cpu_idx);
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
80f6a3adbc
commit
c9d0248867
2 changed files with 23 additions and 0 deletions
|
|
@ -805,6 +805,18 @@ int k_thread_cpu_mask_enable(k_tid_t thread, int cpu);
|
|||
* @return Zero on success, otherwise error code
|
||||
*/
|
||||
int k_thread_cpu_mask_disable(k_tid_t thread, int cpu);
|
||||
|
||||
/**
|
||||
* @brief Pin a thread to a CPU
|
||||
*
|
||||
* Pin a thread to a CPU by first clearing the cpu mask and then enabling the
|
||||
* thread on the selected CPU.
|
||||
*
|
||||
* @param thread Thread to operate upon
|
||||
* @param cpu CPU index
|
||||
* @return Zero on success, otherwise error code
|
||||
*/
|
||||
int k_thread_cpu_pin(k_tid_t thread, int cpu);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1598,6 +1598,17 @@ int k_thread_cpu_mask_disable(k_tid_t thread, int cpu)
|
|||
return cpu_mask_mod(thread, 0, BIT(cpu));
|
||||
}
|
||||
|
||||
int k_thread_cpu_pin(k_tid_t thread, int cpu)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = k_thread_cpu_mask_clear(thread);
|
||||
if (ret == 0) {
|
||||
return k_thread_cpu_mask_enable(thread, cpu);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_CPU_MASK */
|
||||
|
||||
static inline void unpend_all(_wait_q_t *wait_q)
|
||||
|
|
|
|||
Loading…
Reference in a new issue