1

Consider an application with a fixed amount of tasks computation per cycle (let's say 100ms) that's usually done with manual scheduling. With 100 sub-cycles of 1ms, knowing and cutting each calculation task into smaller chunks allowing that in sub-cycle n°43, task 102, 103 and 104 will be perform for example.

The advantage

Everything is under control and determinism is at his peak.

The problem

This method induces a lot of work and allows no to really minor evolutions because everything has to be rescheduled in case of a modification in the workflow.

Also, to ensure this kind of beahvior, WCET of each function has to be calculated and a margin is kept in each sub-cycle to ensure that overflow could be countain in a sub-cycle.

On top of that, the newer application requires the need of much longer "algorithms" that will be run across multiple cycles and are not required to be "real time".

The use of a real-time OS (probably FreeRTOS for various reasons) with a preemption scheduling seems appealing because :

  • Much more room to modify the "hard real time" part : increasing maintainability;
  • Longer computation (low priority) can be done using "margin" kept for "hard real time" part;
  • "hard real time" algorithm doesn't have to be cut in small parts

The question

What kind of software architecture or mechanisms can be used to ensure that, using a real time os with preemption, everything that has to be run in a cycle is indeed run during that cycle ? How to ensure the deterministic behavior and how to verify it ?

2
  • Just curious, does your programming environment and RTOS have support for coroutines?
    – rwong
    Commented Feb 12 at 16:37
  • @rwong : It has, yes.
    – iFlo
    Commented Feb 13 at 9:03

1 Answer 1

3

What kind of software architecture or mechanisms can be used to ensure that, using a real time os with preemption, everything that has to be run in a cycle is indeed run during that cycle ? How to ensure the deterministic behavior and how to verify it ?

What we typically mean by "real time" is that a process must complete within the constraint of a timed schedule for the onset and a timed budget for guaranteed completion. Typically these time constraints are very narrow.

Most computing is only done under much looser constraints, and operating systems are largely left alone to schedule things.

From a software design perspective, the only way to ensure that a real-time process is completed during a cycle, is to analyse the work it does and ensure that it will complete within the allocated budget.

The basics of this would be a timing diagram with measurements of the amount of time, or the possible range of time, that a particular process may consume.

There probably won't exist tools that can statically analyse the code, since there are often complex and non-local interactions, or additional constraints that only the programmer knows, which make it difficult to measure the real possible range of timings.

The complexity of these non-local interactions or latent constraints, and the fact that the analysis has to be done manually, are such that it isn't necessarily trivial to reorganise the scheduling or budgets for real-time processes.

With many systems as well, the issue is not strictly about guaranteeing completion within the budget - since this may be impossible to guarantee theoretically - but about how to correctly react to a violation, and perhaps recover, in the extremely unlikely circumstances that it occurs.

In general, by asking "how do you ensure everything is deterministic?", I'd say you're begging the question that is supposed to be answered by your work as a developer, since establishing a deterministic timing (or timing range) is the difficult part which requires manual analysis - the details and complexity of which is specific to an application.

Once you have timing ranges, actually scheduling them within a budget (or finding that they don't fit) is often relatively straightforward.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.