xiaoxiang781216 commented on a change in pull request #1009: URL: https://github.com/apache/incubator-nuttx/pull/1009#discussion_r422888689
########## File path: arch/sim/src/sim/up_oneshot.c ########## @@ -357,6 +358,16 @@ FAR struct oneshot_lowerhalf_s *oneshot_initialize(int chan, void up_timer_initialize(void) { + /* Block the signals for the new threads created on the host to prevent + * a race condition where the simulated interrupt handler runs on another + * host thread. The new threads will inherit the signal mask which has + * blocked signals. + */ + +#ifdef CONFIG_SIM_PREEMPTIBLE + up_prepare_timer(); Review comment: Yes, up_oneshot.c is the bridge between NuttX and host. up_oneshot.c implmeent the standard NuttX timer driver interface and forward the real timing call(host_sleepuntil) to up_hosttime.c which is part of HOSTSRC. Here is the basic idea to integrate your code into up_oneshot.c: 1.Implment the alaram wrapper and signal handler in up_hosttime.c 2.These functions should forward to your alarm wrapper in up_hosttime.c: oneshot_initialize sim_start sim_cancel it's almost 1:1 mapping for alarm API 3.Signal handler should call to some function(similar with up_timer_update) in up_hosttime.c Of course, we should make sure the code can run without problem with/without CONFIG_SIM_PREEMPTIBLE. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org