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 <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa
2021-07-22 15:24:52 +09:00
committed by Alin Jerpelea
parent a48513ad65
commit b68fc9eb1d
+8 -1
View File
@@ -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;