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 12:43:06 UTC

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

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


##########
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)
+        {
+          mutex = (FAR mutex_t *)tcb->waitobj;
+          syslog(LOG_EMERG, "STATE:WAIT_SEM|%2d, maybe held by %2d\n", tid,

Review Comment:
   should not be %2d, thread id may over than 1000



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

Review Comment:
   move to line 56



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