Skip to content

RT Scheduler Fairness Failure #26

@HeatCrab

Description

@HeatCrab

Background

The rtsched.c application demonstrates Linmo's real-time scheduler feature with a credit-based scheduling algorithm. The test spawns 5 tasks:

  • Task 1, 2, 3: Configured as real-time tasks with credit-based priorities (3, 4, 5 credits respectively)
  • Task 4, 5: Standard non-RT tasks using default round-robin scheduling

Observed Behavior

When running the application on QEMU with preemptive scheduling enabled, the output shows:

[Task 1: 100000]
[Task 1: 100001]
[Task 1: 100002]
[Task 3: 300000]
[Task 3: 300001]
...
Task 3 running
Task 3 running
Task 4 running
Task 4 running
...

Problems identified:

  1. Task 1 executes only 3 times, then stops appearing in the output
  2. Task 2 never executes at all - no output from Task 2
  3. Task 5 never executes - no output from Task 5
  4. Task 3 and Task 4 monopolize the CPU

Expected Behavior

Based on the credit-based scheduler design:

  • Real-time tasks (1, 2, 3) should execute according to their credit allocation:
    • Task 1: 3 credits per cycle
    • Task 2: 4 credits per cycle
    • Task 3: 5 credits per cycle
  • Non-RT tasks (4, 5) should get CPU time when no RT tasks are ready
  • All tasks should have fair access to the CPU over time
  • Output should show interleaved execution of all 5 tasks with RT tasks getting proportional CPU time

Root Cause Analysis

RT tasks are not being selected by the scheduler. The custom_sched() function appears to fail returning valid RT task IDs, causing only non-RT tasks (4, 5) to be scheduled by the fallback mechanism.

Steps to Reproduce

  1. Build and run the rtsched application on QEMU

    make rtsched
    make run
  2. Observe the output

  3. Notice that Task 1, 2, 3 do not appear or appear only briefly

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions