-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arch/sim: Fix the up_cpu_start initialisation on OSX with SMP config enabled #1709
arch/sim: Fix the up_cpu_start initialisation on OSX with SMP config enabled #1709
Conversation
22090af
to
31bc19b
Compare
arch/sim/src/nuttx-names.in
Outdated
@@ -149,6 +149,9 @@ NXSYMBOLS(sched_yield) | |||
NXSYMBOLS(seekdir) | |||
NXSYMBOLS(select) | |||
NXSYMBOLS(sem_destroy) | |||
NXSYMBOLS(sem_open) | |||
NXSYMBOLS(sem_close) | |||
NXSYMBOLS(sem_unlink) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's order the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will order the list
arch/sim/src/sim/up_simsmp.c
Outdated
@@ -53,7 +54,11 @@ | |||
struct sim_cpuinfo_s | |||
{ | |||
int cpu; /* CPU number */ | |||
#ifdef CONFIG_HOST_MACOS | |||
sem_t *done; | |||
#else | |||
sem_t done; /* For synchronization */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we switch to named semp for all platform? it's hard to maintain two codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good idea
arch/sim/src/sim/up_simsmp.c
Outdated
ret = sem_init(&cpuinfo.done, 0, 0); | ||
|
||
#ifdef CONFIG_HOST_MACOS | ||
done_sema = sem_open(g_sema_name_done, O_CREAT, 0644, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name need different for each cpu and for multiple nuttx instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good catch, thanks ! This will not work when we have multiple NuttX instances running. Currently it will work because the thread creation is sequential and we destroy the named semaphore after each CPU initialisation.
After more reviewing, I think we can remove the semphare from the code since the synchronization isn't really needed. |
|
6495dad
to
13a9893
Compare
i suspect it's simpler to use pthread mutex/condvar. |
13a9893
to
82e69d2
Compare
I updated the patch to use pthread_con_t signalling mechanism |
9ea6eb4
to
8a880cd
Compare
## Summary of changes On OSX with CONFIG_SMP=y the semaphore which notifies that the CPU is initialised, is not created and the up_cpu_start() returns with error from sem_init(). This patch fixes the problem by using pthread_cond_t signalling mechanism which is supported on Mac. Signed-off-by: Sebastian Ene <[email protected]>
## Summary of changes The pthread_cond_* API is also present as part of libfs.a and we want to avoid colisions and link with the correct implementation. Signed-off-by: Sebastian Ene <[email protected]>
8a880cd
to
a266317
Compare
LGTM. |
Summary
This PR fixes the issue described in #1708 . On Mac the
sem_init(..)
host call returns with error as unnamed semaphores are not supported. Because of this, the call toup_cpu_start
fails and the simulation hangs.The patch fixes this issue by using pthread_cond_t signalling instead of sempahores.