You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/09 14:12:09 UTC
[incubator-nuttx-apps] branch master updated: testing/smp: Replace
up_cpu_index with sched_getcpu
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 4a13a08 testing/smp: Replace up_cpu_index with sched_getcpu
4a13a08 is described below
commit 4a13a0893f0b5f9577d265d96cbe73ea06bdc7da
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Feb 9 14:57:06 2020 +0800
testing/smp: Replace up_cpu_index with sched_getcpu
---
testing/smp/smp_main.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/testing/smp/smp_main.c b/testing/smp/smp_main.c
index 4c9089d..d27c433 100644
--- a/testing/smp/smp_main.c
+++ b/testing/smp/smp_main.c
@@ -37,6 +37,7 @@
* Included Files
****************************************************************************/
+#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -56,10 +57,7 @@
****************************************************************************/
static pthread_barrier_t g_smp_barrier;
-
-#if defined(CONFIG_SMP) && defined(CONFIG_BUILD_FLAT)
static volatile int g_thread_cpu[CONFIG_TESTING_SMP_NBARRIER_THREADS+1];
-#endif
/****************************************************************************
* Private Functions
@@ -74,18 +72,15 @@ static volatile int g_thread_cpu[CONFIG_TESTING_SMP_NBARRIER_THREADS+1];
*
****************************************************************************/
-#if defined(CONFIG_SMP) && defined(CONFIG_BUILD_FLAT)
-int up_cpu_index(void);
-
static void show_cpu(FAR const char *caller, int threadno)
{
- g_thread_cpu[threadno] = up_cpu_index();
+ g_thread_cpu[threadno] = sched_getcpu();
printf("%s[%d]: Running on CPU%d\n", caller, threadno, g_thread_cpu[threadno]);
}
static void show_cpu_conditional(FAR const char *caller, int threadno)
{
- int cpu = up_cpu_index();
+ int cpu = sched_getcpu();
if (cpu != g_thread_cpu[threadno])
{
@@ -93,10 +88,6 @@ static void show_cpu_conditional(FAR const char *caller, int threadno)
printf("%s[%d]: Now running on CPU%d\n", caller, threadno, cpu);
}
}
-#else
-# define show_cpu(c)
-# define show_cpu_conditional(c)
-#endif
/****************************************************************************
* Name: hog_milliseconds
@@ -232,9 +223,7 @@ int main(int argc, FAR char *argv[])
memset(threadid, 0, sizeof(pthread_t) * CONFIG_TESTING_SMP_NBARRIER_THREADS);
for (i = 0; i <= CONFIG_TESTING_SMP_NBARRIER_THREADS; i++)
{
-#if defined(CONFIG_SMP) && defined(CONFIG_BUILD_FLAT)
g_thread_cpu[i] = IMPOSSIBLE_CPU;
-#endif
if (i < CONFIG_TESTING_SMP_NBARRIER_THREADS)
{
threadid[i] = 0;