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:07:58 UTC

[incubator-nuttx-apps] branch pr59 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 pr59
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/pr59 by this push:
     new d4cd08b  testing/smp: Replace up_cpu_index with sched_getcpu
d4cd08b is described below

commit d4cd08b46d9a1d6af5e29e28780f3bfe2c702fa7
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Feb 9 14:57:06 2020 +0800

    testing/smp: Replace up_cpu_index with sched_getcpu
    
    Change-Id: Ieb52948ad1266f7168a85e3d17b4c79e7957894c
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 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;