Xenomai implements RTOS resource collection and notes

Real time test: detailed explanation of cyclictest
Must understand the process scheduling in Linux system
After reading some information, can it be understood as: tasks of real-time processes and ordinary processes in Linux_ Struct data structure is different; Different scheduling strategies (SCHED_FIFO, SCHED_RR and SCHED_NORMAL) are used, resulting in the process being divided into real-time process and ordinary process
Analysis of completely fair scheduling in Linux -- CFS
View the list of processes in the system and their corresponding real-time priority (RTPRIO). If this column displays -, it is not a real-time process.

ps -eo state,uid,pid,ppid,rtprio,time,comm

linux process scheduling method (SCHED_OTHER,SCHED_FIFO,SCHED_RR)

Using RT tests and Linux Test Project (LTP) to test the real-time performance of the system: Worst Case Latency Test Scenarios.

sudo time cyclictest -t4 -p 99 -i 1000 -n -l 1000000000000 -m
# Generating the disk i/o load
while true; do taskset -c 3 /bin/du / ; done  &

# Generating the CPU load with Ping
taskset -c 0 /bin/ping -l 100000 -q -s 10 -f localhost &
taskset -c 1 /bin/ping -l 100000 -q -s 10 -f localhost &
taskset -c 2 /bin/ping -l 100000 -q -s 10 -f localhost &
taskset -c 3 /bin/ping -l 100000 -q -s 10 -f localhost &

# Generating the Network load
# First start the server...
# then start netperf to connect to the server
/usr/bin/netperf -H <IP_ADDR_OF_SERVER> -t TCP_STREAM -A 16K,16K -l 3600
# Streamming Stress using firefox webbrowser.
firefox http://www.intomail.net/stream.php

At 18:47:07 on January 11, 2022, after studying RT tests package and Linux Test Project package, it is concluded that using CyclicTest can only work on non real-time systems and systems with preempt RT patch (although not tested); If you want to verify the effectiveness of the Cobalt kernel, you must write your own benchmark. You can first refer to how Xenomai's latency benchmark is implemented.

C language programming skills - signal (signal mechanism)
Linux multiprocess programming

At 11:41:20 on February 15, 2022:
Summary of ROS exploration (XXIX) -- Summary of Kung Fu Tea robot project There are many discussions about xenomai in the comments, which can be referred to a wave.


According to the official document, after running / usr/xenomai/bin/latency to check whether there is an error, you have to run the xeno test command to evaluate the system performance. Here is the first pit:

If you run this command directly, you will be prompted that you can't find it. It is recommended that sudo apt install xenomai system tools. The pit is that this system tools corresponds to xenomai version 2.6.4. It is wrong to install it.

Xeno test is actually contained in the / usr/xenomai/bin / directory. It's troublesome to enter / usr/xenomai/bin / xeno test every time here. First, in Add to zshrc:

export PATH=/usr/xenomai/bin:$PATH

Then follow this tutorial "When sudo + command, prompt that the command cannot be found" Configure it.

Then you can enter the example command given by xeno test -- help to see: sudo xeno test - L "dohell - s - M / MNT - L / LTP" - T 2

The entry code is as follows (copied online):

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <alchemy/task.h>
#include <alchemy/timer.h>
#include <math.h>

#define CLOCK_RES 1e-9 //Clock resolution is 1 ns by default
#define LOOP_PERIOD 1e7 //Expressed in ticks
//RTIME period = 1000000000;
RT_TASK loop_task;

void loop_task_proc(void *arg)
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;
  int iret = 0;

  RTIME tstart, now;

  curtask = rt_task_self();
  rt_task_inquire(curtask, &curtaskinfo);
  int ctr = 0;

  //Print the info
  printf("Starting task %s with period of 10 ms ....\n", curtaskinfo.name);

  //Make the task periodic with a specified loop period
  rt_task_set_periodic(NULL, TM_NOW, LOOP_PERIOD);

  tstart = rt_timer_read();

  //Start the task loop
    printf("Loop count: %d, Loop time: %.5f ms\n", ctr, (rt_timer_read() - tstart)/1000000.0);

int main(int argc, char **argv)
  char str[20];

  //Lock the memory to avoid memory swapping for this program
  //As a function provided by Linux, memory exchange will cause real-time tasks to miss deadline. This command will lock the process in RAM
  printf("Starting cyclic task...\n");

  //Create the real time task
  sprintf(str, "cyclic_task");
  rt_task_create(&loop_task, str, 0, 50, 0);

  //Since task starts in suspended mode, start task
  rt_task_start(&loop_task, &loop_task_proc, 0);

  //Wait for Ctrl-C

  return 0;

My c_cpp_properties.json:

    "configurations": [
            "name": "Linux",
            "includePath": [
                "/usr/xenomai/include/*" //It doesn't say that here, stdio H will report an error, what the hell...
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-clang-x64"
    "version": 4

Attempt to install Xenomai on ARM64 platform

The development board used is OK8MM-C, and the CPU of this board is imx8m mini. First, replace the ok8mm Linux kernel / folder in the sdk provided by the government with its own kernel source code.

sudo apt update
sudo apt install gcc-7-aarch64-linux-gnu
sudo apt install gcc-aarch64-linux-gnu
~/Downloads/xenomai-v3.2.1/scripts/prepare-kernel.sh --arch=arm64
mkdir -p ./build/linux
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=./build/linux defconfig
#Yes/ build/linux directory config configuration file. 
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=./build/linux menuconfig
# This sentence is not mentioned in the original tutorial, but it has to be configured, right?

menuconfig interface of arm64 and total difference under x86

* General setup
  --> Local version - append to kernel release: -jiayu
  # `uname -a ` will display additional custom text. It doesn't matter what you write.
* ACPI (Advanced Configuration and Power Interface) Support
  --> Processor (Disable)
* Kernel Features
  --> Multi-core scheduler support (Disable)
* CPU Power Management
  --> CPU Idle
      --> CPU idle PM support (Disable)
  --> CPU Frequency scaling
      --> CPU Frequency scaling (Disable)
* Device Drivers
  --> Graphics support (Disable)
    --> ETNAVIV (DRM support for Vivante GPU IP cores) (Disable)
    # page migration dependency
* Memory Management options
  --> Transparent Hugepage Support (Disable)
  --> Allow for memory compaction (Disable)
  --> Contiguous Memory Allocator (Disable)
  --> Page Migration (Disable)

Compilation starts!

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=./build/linux Image dtbs modules
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=./build/linux modules_install INSTALL_MOD_PATH=/home/jiayu/

Paste the compiled 5.10.76-jiayu folder under / lib/modules in the file system.

reference material

a treasure house! Xenomai General
Real-Time Programming with Xenomai 3 - Part 1: Installation and Basic Setup
Real-Time Programming with Xenomai 3 - Part 2: Writing a simple periodic task.

Added by toasty2 on Wed, 16 Feb 2022 04:05:19 +0200