0

I want to design a scheduler that works in Arinc653 manner just for experimental issues. Is this possible to manipulate the scheduler in this way?

There is time-slicing in threadX I know but all examples I've encountered are using TX_NO_TIME_SLICE (And my shots with that did not work either.). Besides I'm not sure if time-slice make the thread wait until its deadline met or put it into sleep so that other threads get running.

For short; Arinc653 scheduler defines a constant major frame that each 'thread' has its definite amount of running times and repeats major frame endlessly. If a thread assigned with i.e 3ms within a major frame and it finishes its job in 1 ms; kernel still waits 2ms to switch next 'thread'.

tolgayilmaz
  • 3,987
  • 2
  • 19
  • 19

2 Answers2

0

You can use time slicing to limit the amount of time each thread runs: https://learn.microsoft.com/en-us/azure/rtos/threadx/chapter4#tx_thread_create

0

I understand that the characteristic of of the Arinc653 scheduler that you want to emulate is time partitioning. The ThreadX schedule policy is based on priority, preemption threshold and time-slicing.

You can emulate time partitioning with ThreadX. To achieve that you can use a timer, where you can suspend/resume threads for each frame. Timers execute in a different context than threads, they are light weight and not affected by priorities. By default ThreadX uses a timer thread, set to the highest priority, to execute threads; but to get better performance you can compile ThreadX to run the timers inside an IRQ (define the option TX_TIMER_PROCESS_IN_ISR).

An example:

  • Threads thd1,thd2,thd3 belong to frame A
  • Threads thd4,thd5,thd6 belong to frame B
  • Timer tm1 is triggered once every frame change

Pseudo code for tm1:

tm1()
{
  static int i = 0;
  if (i = ~i)
  {
    tx_thread_suspend(thd1);
    tx_thread_suspend(thd2);
    tx_thread_suspend(thd3);
    tx_thread_resume(thd4);
    tx_thread_resume(thd5);
    tx_thread_resume(thd6);
  }
  else
  {
    tx_thread_suspend(thd4);
    tx_thread_suspend(thd5);
    tx_thread_suspend(thd6);
    tx_thread_resume(thd1);
    tx_thread_resume(thd2);
    tx_thread_resume(thd3);
  }
}
Andrés
  • 51
  • 3
  • This may worth try but not seems intuitive. I guess threadx has an elegant way to do that. Anyway, other options include modifying the scheduler if we are allowed to to that. – tolgayilmaz Nov 09 '21 at 04:35