sched: add smp function call

Support smp function call, calling smp_call_function allows
a specific core to execute a function. It should be noted
that there should be no waiting operations in the executed
function.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21
2023-09-26 10:06:49 +08:00
committed by Xiang Xiao
parent b5d640acc5
commit 34412349e9
6 changed files with 388 additions and 0 deletions
+12
View File
@@ -1581,6 +1581,18 @@ void up_secure_irq(int irq, bool secure);
# define up_secure_irq(i, s)
#endif
#ifdef CONFIG_SMP_CALL
/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu
*
****************************************************************************/
void up_send_smp_call(cpu_set_t cpuset);
#endif
/****************************************************************************
* Name: up_secure_irq_all
*
+68
View File
@@ -28,6 +28,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>
#include <sched.h>
#include <signal.h>
@@ -743,6 +744,12 @@ begin_packed_struct struct tcbinfo_s
typedef CODE void (*nxsched_foreach_t)(FAR struct tcb_s *tcb, FAR void *arg);
/* This is the callback type used by nxsched_smp_call() */
#ifdef CONFIG_SMP_CALL
typedef CODE int (*nxsched_smp_call_t)(FAR void *arg);
#endif
#endif /* __ASSEMBLY__ */
/****************************************************************************
@@ -1566,6 +1573,67 @@ pid_t nxsched_getppid(void);
size_t nxsched_collect_deadlock(FAR pid_t *pid, size_t count);
#ifdef CONFIG_SMP_CALL
/****************************************************************************
* Name: nxsched_smp_call_handler
*
* Description:
* SMP function call handler
*
* Input Parameters:
* irq - Interrupt id
* context - Regs context before irq
* arg - Interrupt arg
*
* Returned Value:
* Result
*
****************************************************************************/
int nxsched_smp_call_handler(int irq, FAR void *context,
FAR void *arg);
/****************************************************************************
* Name: nxsched_smp_call_single
*
* Description:
* Call function on single processor
*
* Input Parameters:
* cpuid - Target cpu id
* func - Function
* arg - Function args
* wait - Wait function callback or not
*
* Returned Value:
* Result
*
****************************************************************************/
int nxsched_smp_call_single(int cpuid, nxsched_smp_call_t func,
FAR void *arg, bool wait);
/****************************************************************************
* Name: nxsched_smp_call
*
* Description:
* Call function on multi processors
*
* Input Parameters:
* cpuset - Target cpuset
* func - Function
* arg - Function args
* wait - Wait function callback or not
*
* Returned Value:
* Result
*
****************************************************************************/
int nxsched_smp_call(cpu_set_t cpuset, nxsched_smp_call_t func,
FAR void *arg, bool wait);
#endif
#undef EXTERN
#if defined(__cplusplus)
}