apache / apache/nuttx

Bug: sporadic scheduling does not work for multiple threads

Open
#2,935 16 comments 0 reactions 1 assignee Claimed by @patacongo View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

Hi,

I am using NuttX for micro-ROS on STM32 microcontroller on Olimex board. [Link to example](https://github.com/micro-ROS/nuttx_apps/blob/feature/foxy_rbs_one_sporadic_thread/examples/uros_rbs/main_rbs.c)

which is a very simple extension of the [NuttX example for sporadic scheduling in testing/ostest](https://github.com/micro-ROS/nuttx_apps/blob/feature/foxy_rbs_one_sporadic_thread/testing/ostest/sporadic.c)

**Test setup:**
- [sporadic thread 1 configuration: 20ms/100ms budget/period](https://github.com/micro-ROS/nuttx_apps/blob/6f692d9bfcb0e3d1971e2b2a6448d1084d5a81ea/examples/uros_rbs/main_rbs.c#L367)
- [sporadic thread 2 configuration 10ms/100ms budget/period](https://github.com/micro-ROS/nuttx_apps/blob/6f692d9bfcb0e3d1971e2b2a6448d1084d5a81ea/examples/uros_rbs/main_rbs.c#L399)
- the callback function [increments a counter every millisecond](https://github.com/micro-ROS/nuttx_apps/blob/6f692d9bfcb0e3d1971e2b2a6448d1084d5a81ea/examples/uros_rbs/main_rbs.c#L174).
- [wait for 10 seconds](https://github.com/micro-ROS/nuttx_apps/blob/6f692d9bfcb0e3d1971e2b2a6448d1084d5a81ea/examples/uros_rbs/main_rbs.c#L464)
- output the [number of ms-counters](https://github.com/micro-ROS/nuttx_apps/blob/6f692d9bfcb0e3d1971e2b2a6448d1084d5a81ea/examples/uros_rbs/main_rbs.c#L476) for every sporadic thread

**Observation:**
- When I configure the application with one sporadic thread and one FIFO thread (with lower priority and 100% CPU utilization), budget enforcement works well.
- When I configure the application with two sporadic threads and one FIFO thread (with lower priority and 100% CPU utilization) budget enforcement does not work any more. I tested the sporadic scheduling with different budget/period configurations: 10ms/100ms and 1second/10seconds (the internal tick - conversion was correct).
- I saw also somewhere the requirement that the buget shall be at most half of the period, so I configured the budget always smaller then half of the period for all individual threads:
- thread 1: 20ms/100ms
- thread 2: 10ms/100ms

**Problem description**
I came to the conclusion, that budget enforcement of the NuttX sporadic scheduling only works for one sporadic thread.
For real applications, I would like to use multiple threads with sporadic scheduling.

Could you please check the implementation and give support?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.