I am very new to freertos and was trying to modify the demo program for Posix-GCC on
linux.
How can we set the deadline for tasks? And how can we find the actual execution time?
I was trying to implement a simple LST (Least Slack Time first) scheduling algorithm
(just to get a hang of it not going to apply it yet) as part of an RTS course.
Needed deadline and execution time to calculate slack.
You can use something like run-time stats to see the percentage of CPU time allocated to each task. The scheduling algorithm is fixed though - other than options to turn preemption and time slicing on or off.
The scheduling algorithm is fixed meaning we cannot even simulate (donât know if thatâs the term) scheduling algorithsm like Earliest deadline first, Least slack time first, Rate monotonic, Deadline monotonic and all (just throwing terms I had heard here)?
Which scheduling algorithm does FreeRTOS use? Any idea?
The scheduling of FreeRTOS is highest priority scheduling with round robin in a priority.
Some other methods like rate monotonic, which are static priority systems, can just be mapped to FreeRTOS priorities.
Systems with dynamic priorities would need you to add some special âschedulerâ to the system that adjusted the FreeRTOS task priorities to map them to make them ordered by that scheduling rule. This likely needs this scheduler to keep some extra information about the tasks that FreeRTOS doesnât keep now.
Excuse the question, but do you know how to read C code? FreeRTOS is really well written. Everything related to tasks and task scheduling is encapuslated in (appropriately named) tasks.c, so understanding the scheduling control flow once you know where to look isnât too hard and also seems like the prerequirement to manipulating it.
The short answer, though, is: Look at taskSELECT_HIGHEST_PRIORITY_TASK(). Already the name should give away what it does and how it fits into the picture. Likewise vTaskStartScheduler() which does nothing but kick start the OS by assigning the CPU to the first ready task. The scheduler takes over every time a task loses the CPU afterwards (or some event enforces a task switch). Function and macro names arenât arbitrary.
Apologies if this remark should sound rude, but in âmy days,â the name of a source file to open used to be all it took to do the rest oneself.
One of the good things about software is that you canât wreck it like one can wreck a car. If worst comes to worst, it crashes on your target (leaving no physical harm to anything or anybody involved), then you simply try something else until you get it to work.
Sorry for having been rudish earlier on. If you arenât familar with coding at all yet, scheduling algorithms are indeed a fairly tall order to digest code wise.