You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/25 13:33:01 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7426: mutex:move mutex holder to struct mutex_s.

pkarashchenko commented on code in PR #7426:
URL: https://github.com/apache/incubator-nuttx/pull/7426#discussion_r1004495297


##########
libs/libc/sched/sched_dumpstack.c:
##########
@@ -55,6 +55,26 @@ void sched_dumpstack(pid_t tid)
 {
   int size = DUMP_DEPTH;
   int skip;
+  FAR struct tcb_s *tcb = NULL;
+  FAR mutex_t *mutex = NULL;
+
+  /* If task is in TSTATE_WAIT_SEM, it may be waiting for a mutex,
+   * then print mutex holder to help debugging.
+   * However, if it is not a mutex, an invalid holder is printed.
+   * I think printing invalid value is acceptable since this is
+   * for debugging only.
+   */
+
+  if (tid >= 0)
+    {
+      tcb = nxsched_get_tcb(tid);
+      if (tcb != NULL && tcb->task_state == TSTATE_WAIT_SEM)

Review Comment:
   let's check the wait object. If semaphore has `PRIOINHERIT_FLAGS_ENABLE` flag then most probably it is a mutex and we can upcast it to mutex_t. That is one of the possible variants



-- 
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-unsubscribe@nuttx.apache.org

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