jlaitine commented on code in PR #16194:
URL: https://github.com/apache/nuttx/pull/16194#discussion_r2059085409


##########
sched/semaphore/sem_wait.c:
##########
@@ -218,6 +271,16 @@ int nxsem_wait_slow(FAR sem_t *sem)
 #endif
     }
 
+  /* If this now holds the mutex, set the holder TID and the lock bit */
+
+  if (mutex && ret == OK)

Review Comment:
   Can you clarify where do you see the race? 
   
   This is the correct place where you know that this task is the holder of the 
mutex (unless the wait failed of course, hence checking the error -  timed wait 
functions still need to work for mutexes even though signals can't interrupt 
them). It has just acquired it and is running - and still inside the critical 
section with the blocking bit set.
   
   The only reason why sem_post needs to set the holder (apart from releasing 
the last holder of the mutex when no other is blocked) is, that the task who is 
being posted may be blocked by something else. If some higher priority task 
again acquires (and blocks on) the mutex, the sem_wait needs to allocate and 
store the holder structure.
   
   But it always needs to be set here still.
   



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