Yocto tool for real time thread minitoring

Bootloader: U-Boot

Kernel version: 5.4.193-5.7.1-devel+git.1895b0052289 (oe-user@oe-host) (gcc version 9.3.0 (GCC)) #1 SMP PREEMPT Mon Sep 25 08:49:04 UTC 2023
Kernel command line: root=PARTUUID=900ce727-02 ro rootwait console=tty1 console=ttymxc2,115200 consoleblank=0 earlycon
Distro name: Not known
Distro version: Not known
Hostname: verdin-imx8mp-tf3-controller-07011727

Hardware info

HW model: Toradex Verdin iMX8MP Q 4GB WB IT

Toradex version: V1.0C
BSP version 5.7.2
Processor arch: Arm

I am working on implementing thread priority using pthread for yocto platform and want to know if this can actually be done and used like RTOS. Is there any tool in yocto/linux like SEGGER Systemview for real-time analysis?

  • Here is the steps and test I performed to test this out.

  • Steps followed to set thread priority.
    (1) Initializing thread attributes using pthread_attr_init().
    (2) Setting the inherit-scheduler attribute of the thread to PTHREAD_EXPLICIT_SCHED using pthread_attr_setinheritsched().
    (3) Setting the scheduling policy SCHED_RR using pthread_attr_setschedpolicy().
    (4) Getting scheduling parameter attributes using pthread_attr_getschedparam().
    (5) Setting thread priority using pthread_attr_setschedparam().
    (6) Created thread with set attribute parameters.

  • How I have tested.

  • Test

  • I first created 10 threads all with priority from 1 to 10 and a print log.

  • Started all threads one by one.

  • I have confirmed that the priority is getting set for each thread.

  • Output expected.
    → After few seconds, the prints from all threads should be in-order as per set priority.
    print: Thread 10 priority 10
    print: Thread 9 priority 9
    print: Thread 8 priority 8

  • Actual observed Output.
    → The prints are coming randomly without following any specific order even after a min or so.

  • I did find few articles (related to raspberry pi) mentioning about the fact that this can only be applicable if the processor only has one core.

  • If there is multiple core is present then the thread can be assign to different cores randomly.

  • Link: https://forums.raspberrypi.com/viewtopic.php?t=328682

  • Linux is not RTOS though some improvements can be implemented to enhance its real-time capabilities.
  • The Verdin iMX8MP Q 4GB WB IT has multiple (four) cores.

Real-Time Linux | Toradex Developer Center
Linux process priorities demystified