zzby0 opened a new pull request, #17900:
URL: https://github.com/apache/nuttx/pull/17900

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   This PR fix deadlock in sim by replacing wdog with work queue.
   
   wdog-related deadlocks: Watchdog callbacks were executed in the host's 
signal handler context, which has strict limitations. Signal handlers should 
not call non-async-signal-safe functions (e.g., sim_alsa uses mutex_lock in 
watchdog callbacks, causing deadlocks).
   
   work queue dependency deadlock: RPMSG work in HPWORK was waiting for remote 
buffer callbacks that also execute in HPWORK, creating a circular dependency 
deadlock.
   
   Initialization ordering issue: The usrsock module registers work in 
net_initialize() before g_work_queue is created, causing race conditions.
   
   Changes:
   
   Commit 7056084d907: Replace watchdog timers with work queues for periodic 
tasks
   Moves periodic task execution from signal handler context to work queue 
context
   Only replaces wdog usage for periodic tasks; other interrupt callbacks 
remain in signal handler
   Affects: sim_alsa, sim_netdriver, sim_rpmsg_virtio, sim_rptun, sim_usbdev, 
sim_usbhost
   
   Commit be4a9a695ce: Introduce global work queue to replace HPWORK usage
   Creates dedicated sim_loop_wq work queue for simulator periodic operations
   Breaks the circular dependency in RPMSG by separating work execution contexts
   Affects: Same files as commit 1, plus sim_usrsock
   
   Commit d6724b7245f: Fix initialization order by moving work queue creation 
to IRQ initialization
   Moves g_work_queue creation from up_initialize() to up_irqinitialize()
   Ensures work queue is available before network initialization
   Refactors platform-specific IRQ initialization into host_irqinitialize()
   
   ## Impact
   
   Architecture: Changes only affect the simulator (arch/sim) architecture
   Build: No configuration or build system changes required
   Runtime behavior: Fixes deadlocks without changing external API or 
functionality
   Compatibility: Fully backward compatible; no user-facing changes
   Performance: Minimal impact; work queue scheduling overhead is negligible 
compared to avoided deadlocks
   
   ## Testing
   
   ostest & monkey test
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to