RobinK2 / ESFree

ESFree
Other
24 stars 7 forks source link

Partition based hard real-time scheduler #3

Open tolgayilmaz86 opened 5 years ago

tolgayilmaz86 commented 5 years ago

Hi, I appreciate you have a very good work there which not many similar works done. I wanted to use your work to scehdule my tasks, which have hard and defined start and end times. All my tasks' priority are equal and they have a major frame time like 20ms which they periodically runs in. So I think I need to modify the code. Could you give me any hints about this?

RobinK2 commented 5 years ago

Hi, I am really glad you like ESFree and consider using it! If you have several periodic tasks running with fixed priority I would actually suggest to use RMS( Rate-Monotonic Scheduling) or DMS (Deadline-Monotonic Scheduling) in anyway since those are optimal scheduling policies for fixed priority and guarantees schedulability (no deadlines are missed) if the CPU utilization is less than 69 %. But if you know what you are doing and want to have equal priority in anyway, it was a while ago I touched this code, but I think it should be enough if you do following:

  1. commenting out line 795: xHighestPriority--; in scheduler.c assuming you set the scheduling policy as RMS or DMS
  2. set xHighestPriority = configMAX_PRIORITIES - 1 at line 761
  3. set xHighestPriority = schedSCHEDULER_PRIORITY - 1 at line 759
RobinK2 commented 5 years ago

I have also added link to documentation now (http://www.diva-portal.org/smash/get/diva2:1085303/FULLTEXT01.pdf) fyi.

tolgayilmaz86 commented 5 years ago

thank you for your interesest, I will try to modify RMS but the way I need to implement should not assume priorities of any task created by user since they will be all same. Also task sequence are predetermined with no change assumed. So the scheduler will sort them by their release time. However I infer that the scheduler task you used is not designed to work with rms. If I use freertos scheduler scheduler.c will not get called any more after prvPeriodicTaskCode runs statement pxThisTask->pvTaskCode( pvParameters ) since my tasks are already in an infinite loop.

RobinK2 commented 5 years ago

So you mean that all tasks have same period? Then all task will also get same priority with RMS. Have you tested that?

Correct me if I´m misunderstanding, but you mean that the RMS implementation doesn´t work because you have put infinite loops in your tasks? You´re right that periodic tasks with infinite loops are problematic since it is not really designed for that. It assumes that tasks finishes before their maxExecTime. But there is still one option, you can enable TIMING_ERROR_DETECTION_EXECUTION_TIME feature, and it shall manage all tasks that runs with infinite loops as well. It will suspend all tasks that reaches their maxExecTime until next period.

tolgayilmaz86 commented 5 years ago

thank you, you are keeping giving me valuable ideas. I will try these later.