hujun260 commented on code in PR #18199:
URL: https://github.com/apache/nuttx/pull/18199#discussion_r2734906889


##########
sched/semaphore/sem_clockwait.c:
##########
@@ -137,14 +137,14 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
 
           ret = nxsem_wait(sem);
 
+          leave_critical_section(flags);

Review Comment:
   
   
   
   
   > ```
   > T1                                      T2
   > 
   > nxsem_wait
   > |
   > leave_critical_section
   > |
   >  -------------------------------------->nxsem_wait
   >                                         |
   >                                          ->wd_start
   > |<--------------------------------------
   > |
   > wd_cancel
   > ```
   > 
   > I mean 2 tasks are contending for the same lock.
   
   > ```
   > T1                                      T2
   > 
   > nxsem_wait
   > |
   > leave_critical_section
   > |
   >  -------------------------------------->nxsem_wait
   >                                         |
   >                                          ->wd_start(&rtcb_t2->waitdog)
   > |<--------------------------------------
   > |
   > wd_cancel(&rtcb_t1->waitdog)
   > ```
   
   Even if this happens, it won't cause any issues. Since rtcb_t1->waitdog and 
rtcb_t2->waitdog are different, both can run normally without contention.
   



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