wangchdo commented on code in PR #17223:
URL: https://github.com/apache/nuttx/pull/17223#discussion_r2467748558


##########
include/nuttx/event.h:
##########
@@ -73,7 +73,6 @@ struct nxevent_s
 {
   struct list_node         list;   /* Waiting list of nxevent_wait_t */
   volatile nxevent_mask_t  events; /* Pending Events */
-  spinlock_t               lock;   /* Spinlock */

Review Comment:
   > I think there needs to be a balance here with the SMP mode, I prefer to 
use spinlock
   
   Hi @anchao 
   
   The current event implementation uses a **spinlock plus a semaphore** — the 
spinlock protects the event object, while the semaphore manages synchronization 
between the event waiter and poster. However, this design feels unnecessarily 
heavy. The semaphore internally relies on 
**enter_critical_section()/leave_critical_section()** to protect its own 
object, and its internal logic is overly complex for such a simple 
synchronization scenario. In addition, the semaphore object itself consumes 
extra memory.
   
   Therefore, I decided to remove the semaphore dependency and instead directly 
use **enter_critical_section()/leave_critical_section()** to both protect the 
event object and synchronize between the waiter and poster. This should be more 
efficient



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