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


##########
include/nuttx/sched.h:
##########
@@ -253,6 +253,7 @@ enum tstate_e
   TSTATE_TASK_INACTIVE,       /* BLOCKED      - Initialized but not yet 
activated */
   TSTATE_WAIT_SEM,            /* BLOCKED      - Waiting for a semaphore */
   TSTATE_WAIT_SIG,            /* BLOCKED      - Waiting for a signal */
+  TSTATE_WAIT_EVENT,          /* BLOCKED      - Waiting for a event */

Review Comment:
   @xiaoxiang781216 @anchao  
   
   This PR removed event's reliance on semaphore, I also submited a PR to 
remove event's reliance on a separate wait object, please also check :[ PR17244 
](https://github.com/apache/nuttx/pull/17244)
   
   
   https://github.com/apache/nuttx/pull/17223 plus this 
https://github.com/apache/nuttx/pull/17224 **change summary** is:
   
   Refactors the event module by removing its dependency on semaphores and 
separate wait objects, and introduces a new task state TSTATE_WAIT_EVENT to 
simplify scheduling and improve maintainability.
   
   **Detailed Changes** are
   
   **1. Remove semaphore dependency
   Reason:**
   - Semaphore objects consume more memory than necessary for event 
synchronization.
   - Semaphore interfaces are relatively complex, involving global locks and 
logic that exceeds
   the needs of the event mechanism.
   **Benefit:**
   - Simplifies the event module and reduces runtime and memory overhead.
   **2. Remove wait object dependency
   Reason:**
   - Wait objects introduce additional memory usage.
   - The current design either uses a local wait object in the waiting task 
(which is unsafe because the posting task also accesses it) or requires users 
to define global wait objects and call event_tickwait_wait(). This leads to 
complicated and error-prone usage.
   - By removing wait objects, the event module can be implemented more cleanly.
   **Benefit:**
   - Simplifies API usage.
   - Improves safety and code maintainability.
   
   **3. Introduce TSTATE_WAIT_EVENT and move the scheduling list to the event 
object
   Reason:**
   - Makes the event module implementation more concise.
   - Allows the scheduler to handle tasks blocked on events more flexibly in 
special cases (e.g., task deletion).
   **Benefit:**
   - Improves modularity and better integrates event handling with the 
scheduler.



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