You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2021/07/22 07:47:29 UTC

[incubator-nuttx] branch master updated: arch: sim: Workaround to make the IPI work on macOS

This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b68fc9e  arch: sim: Workaround to make the IPI work on macOS
b68fc9e is described below

commit b68fc9eb1d48ad0927873ad037d89efb9cea89ef
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Thu Jul 22 15:24:52 2021 +0900

    arch: sim: Workaround to make the IPI work on macOS
    
    Summary:
    - I noticed that sim:smp does not work correctly on macOS
      due to the recent changes
    - Actually, it can not receive the IPI host signal, so if
      a new task is scheduled on CPU1/2/3, it hangs.
    - Finally, I found the issue depends on pthread stack settings
      and perhaps it might affect the host signal handling.
    - This commit fixes this issue by just reverting the pthread
      stack setting only for macOS.
    
    Impact:
    - sim:smp on macOS
    - Stack usage for CPU1/2/3 IDLE will be incorrect
    
    Testing:
    - Tested with ostest on macOS 11.4 (x86_64)
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 arch/sim/src/sim/up_simsmp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/sim/src/sim/up_simsmp.c b/arch/sim/src/sim/up_simsmp.c
index c802675..47337d8 100644
--- a/arch/sim/src/sim/up_simsmp.c
+++ b/arch/sim/src/sim/up_simsmp.c
@@ -212,7 +212,6 @@ int up_cpu_index(void)
 int sim_cpu_start(int cpu, void *stack, size_t size)
 {
   struct sim_cpuinfo_s cpuinfo;
-  pthread_attr_t attr;
   int ret;
 
   /* Initialize the CPU info */
@@ -227,11 +226,19 @@ int sim_cpu_start(int cpu, void *stack, size_t size)
    * in a multi-CPU hardware model.
    */
 
+#ifdef __APPLE__
+  /* NOTE: workaround to make IPI work on macOS */
+
+  ret = pthread_create(&g_cpu_thread[cpu],
+                       NULL, sim_idle_trampoline, &cpuinfo);
+#else
+  pthread_attr_t attr;
   pthread_attr_init(&attr);
   pthread_attr_setstack(&attr, stack, size);
   ret = pthread_create(&g_cpu_thread[cpu],
                        &attr, sim_idle_trampoline, &cpuinfo);
   pthread_attr_destroy(&attr);
+#endif
   if (ret != 0)
     {
       goto errout_with_cond;