xiaoxiang781216 commented on a change in pull request #5204:
URL: https://github.com/apache/incubator-nuttx/pull/5204#discussion_r819810584



##########
File path: drivers/input/ajoystick.c
##########
@@ -526,12 +461,7 @@ static ssize_t ajoy_read(FAR struct file *filep, FAR char 
*buffer,
 
   /* Get exclusive access to the driver structure */
 
-  ret = ajoy_takesem(&priv->au_exclsem);
-  if (ret < 0)
-    {
-      ierr("ERROR: ajoy_takesem failed: %d\n", ret);
-      return ret;
-    }
+  flags = enter_critical_section();

Review comment:
       > Probably you are right, but the usage of semaphore gives us exclusive 
access with waiting for a task context while critical section resolves mutual 
exclusion between task and interrupt context inside the driver. I mean that 
only one of multiple callers of `ajoy_read` will call 
`lower->al_sample()`+return from `al_sample` with semaphore and multiple 
callers will call `lower->al_sample()` in case if critical section is used and 
`al_sample()` call a pending primitive. That is conceptually difference that 
I'm trying to clarify the behavior.
   
   You mean al_sample may switch out inside critical section? Yes, if it wake 
up a high priority thread.




-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to