How to make the list of all treads in ChibiOS 21?

Discussions and support about ChibiOS/RT, the free embedded RTOS.
alexblack
Posts: 267
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 30 times
Contact:

How to make the list of all treads in ChibiOS 21?

Postby alexblack » Wed Jun 23, 2021 6:23 pm

Hi.
For the debug purposes I need to make a list of all threads in the system. In previous versions I used this code:

Code: Select all

  thread_t *ctp;
  /* Scanning registry.*/
  ctp = ch.rlist.newer;
  do {
    /* Exclude IDLE THREAD from list */
    if (ctp->hdr.pqueue.prio != IDLEPRIO)   {
      /* Fill elements with current task information */
      Info.TaskID     = (uint32_t) ctp;
      Info.sName      = ctp->name;
      Info.Prio       = ctp->hdr.pqueue.prio;
      Info.StackBase  = (uint32_t) ctp->wabase;
      Info.StackSize  = (uint32_t) 0;
    }
   
    /* search next thread */
    sts = chSysGetStatusAndLockX();
    ctp = ctp->newer;
    if (ctp == (thread_t *)&ch.rlist) {
      ctp = NULL;
    }
    chSysRestoreStatusX(sts);
  } while (ctp != NULL);

Now it does not compiling because all structures was changed.
Please help to make this.

User avatar
Giovanni
Site Admin
Posts: 13632
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 890 times
Been thanked: 770 times
Contact:

Re: How to make the list of all treads in ChibiOS 21?

Postby Giovanni » Wed Jun 23, 2021 7:21 pm

Hi,

In order to scan the registry you need to use chRegFirstThread() and chRegNextThread() functions, it is not appropriate to use the pointers directly.

If you need an example then look at the "threads" shell command in /os/various/shell/shell_cmd.c

Giovanni

alexblack
Posts: 267
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 30 times
Contact:

Re: How to make the list of all treads in ChibiOS 21?

Postby alexblack » Thu Jun 24, 2021 7:01 am

Thank you.


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 1 guest