Data structure for Real Time task scheduling

Thread Starter

rt694157

Joined Dec 15, 2019
21
I have done a lot of search on Google about it but I cannot find a clear idea about real time scheduling.
https://en.wikipedia.org/wiki/Real-time_operating_system#Scheduling

Real time scheduling indicate that response should be guaranteed within a specified timing constraint or system should meet the specified deadline. For example flight control system, real-time monitors etc.

You can also tell your point from the pseudo code so that I will get an idea to understand real time scheduling

Can anyone explain what structure should be there for real time system in plain c language ?

C:
#include<headerflie.h>

typedef struct RealTimeS
{
    
}

void main ()
{
    
    
}
Thank you for your any kind of help
 

MrSoftware

Joined Oct 29, 2013
1,665
Are you on a PC or a microcontroller?

Assuming you're on a microcontroller, guaranteeing real-time behavior is more complex than just a couple of function calls. In the simplest of situations, such as basic communication protocols (serial, SPI, I2C), simple PWM, etc.. you can get away with using one of the processor timers. But the results might not be super precise and it's easy to mess things up. For anything more complicated, such as the flight controller you mentioned in your post, you should really start looking at Real Time Operating Systems. Do some reading on FreeRTOS and see if it's in line with what you're looking for.
 

ApacheKid

Joined Jan 12, 2015
140
What we refer to as 'real time' is very dependent on the application, the term itself is historic and originally meant systems where results were delivered more or less as needed. Early computer systems were 'batch' where you run the app at some time of day and got the results the next day.

Real time thus came to mean getting results as needed, where the delay in getting them was not the dominant time element in the system.

The data structures and algorithms involved in scheduling actuall don't differ much between real time OS and conventional OS, scheduling is scheduling.
 

ci139

Joined Jul 11, 2016
1,088
this really depends on your "processor power" e.g. "parallel processing" all the tasks that are scaled by their time demand under the 100% CPU load
and/or processing the tasks at request & updating data/output at ASAP intervals ← but the least goes fast to a REAL mess if inputs depend on outputs

in one graphics screen scrolling app - the best visual results were obtained when running "on demand" change that was set to "update" at mixed times -- so , that the mouse cursor movement was kept appart from the picture re-positioning
it was done such , that when mouse.Bt.Dn the mouse coordinates (start coordinates) were fetched and
on the mouse move
if image was not actively being reloaded it was set to reload (at "intermediate" *end coordinates and these were shifted to start coordinates)
// e.g. if there was CPU time for it (graphics update)
if the image was actively being loaded the mouse was ignored
when the mouse.Bt.Up ocurred the actual position shift was determined (end coordinates)

so . . . all ↑this↑ depends on a specific task set to be performed (and desired result) ← this worked similar on all platforms*

there was made an improvement to above "algorithm" -- but that improvement was an improvement with one graphics card . . . while with another it induced horrible flickering (if i remember right the OS was the same but the computer boards had a couple of years of release time difference & the graphics adapters were different)

so . . . it's also a hw/sw *platform combined with the "algorithm" dependent
 

402DF855

Joined Feb 9, 2013
161
You haven't given enough context in my opinion to give a very meaningful answer. But something like this might be what you have in mind:
C:
typedef struct {
	unsigned int taskid;
	unsigned int priority;
	StackDef_t stack;
} TASK;
 

ci139

Joined Jul 11, 2016
1,088
unsigned int priority;
in the past in my case the priority was defined dual as say
"weight" -- an interrupt density(-level)
"relevance" -- i had about 50% determined order for the processes which had to be processed before the others
while the "process identifier" was basically a bit flag of the two preceeding values (←there might have been more fields in) ← i was able to use the bitmap process names coz it was a relatively simple math computation + visualizing tool
↑↑
↑ The required structure basically "defines itself" when you ran any GUI (mouse,keyboard,screen updates + involved computations + background processes + more) and attempt to optimize it's response×performance times ... there will be only few ways of doing this , of which , even lesser ways can be implemented easy + can be implemented so that the optimum inter-relational-"structure" for a particular programming language specifics is obtained
 
Top