Top Two Mistakes In Main Loop Scheduling

Top Two Mistakes In Main Loop Scheduling - Hallo gues welcome to my blog, you can read this article with title Top Two Mistakes In Main Loop Scheduling, Happy reading

IMPORTANT, MUST BE READ... : Top Two Mistakes In Main Loop Scheduling
Title : Top Two Mistakes In Main Loop Scheduling

Read More


Top Two Mistakes In Main Loop Scheduling

IMPORTANT, MUST BE READ...

In my previous posting I showed yous how to create a multi-rate master copy loop. In this posting we're going to start excavation into the critical number of how to produce timing analysis for a multi-rate master copy loop cooperative scheduler. I'll explicate the superlative 2 mistakes I regard inwards manufacture code that Pb to missed work deadlines.

I'm going to assume your multi-rate master copy loop is implemented to a greater extent than or less the way I described inwards my previous weblog posting. The of import holding nosotros attention virtually is whether each work gets to run to completion old inside its assigned fourth dimension period.

Multi-Rate Main Loop CPU Utilization

Let's state yous receive got a laid of tasks that looks similar this, amongst the tabular array columns beingness the work number, the menses the work runs at (in msec), as well as the amount of CPU fourth dimension it takes to run the work (again inwards msec):

Task  Period  Compute   
 0       five       1    
 1      10       2    
 2      20       three        
 3     100      11     

In this example, Task 2 runs i time every twenty msec, as well as takes three msec to run i time it has started.

Here is the start big question: is the CPU overloaded to to a greater extent than than 100%? To response that, for each row inwards the tabular array add together a CPU % that is computed yesteryear dividing each task's run fourth dimension yesteryear its period. For instance work 2 runs three msec out of every twenty msec, as well as then the CPU utilization is 3/20 = 15%.

Task  Period  Compute  CPU Load 
 0       five       1       20%
 1      10       2       20%
 2      20       three       15%    
 3     100      11       11%
         Total CPU Load  66%

OK, full CPU charge is solely 66%.  This is practiced intelligence as well as then far.

To produce this math inwards the existent world, yous too demand to add together inwards the CPU fourth dimension spent yesteryear interrupt service routines. Sometimes yous destination upward amongst to a greater extent than than 100%, as well as that is manifestly a problem.

It mightiness seem impossible to larn this wrong. But I would non hold out writing this if I hadn't seen this work inwards a existent manufacture pattern review. More than once. The way teams larn this incorrect is non yesteryear getting the math wrong. The work is that they don't produce the analysis inwards the start place, as well as receive got no thought what their CPU charge is because they never stair out it.

An particularly tricky work is when a work mightiness unremarkably run quickly, but i time inwards a spell has a rattling long compute time. This agency that the organisation mightiness come across its deadlines most of the time, but non all the time. If yous were to monitor typical CPU charge on a testbed things would hold out fine. But yous mightiness nevertheless immature lady deadlines i time inwards a spell -- possibly solely i time inwards a actually long spell that yous don't regard during organisation test.

When doing a CPU loading calculation, the compute fourth dimension has to hold out the worst instance path through each as well as every work inwards the code (sometimes called Worst Case Execution Time: WCET), non exactly a typical path. Determining WCET tin laissez passer on the axe hold out a fleck of a pain, but doing as well as then for each work -- fifty-fifty the rattling infrequent ones, is a required start stair inwards knowing if yous are going to immature lady deadlines.


Blocking Time

But we're non out of the woods yet! It is pretty slow to pattern a organisation that misses deadlines despite depression CPU loads. Have yous spotted the work amongst the instance work laid higher upward yet?

The number is that inwards a non-preemptive organisation similar this i time a work starts running, it runs to completion. If it is an infrequent work it mightiness draw of piece of work concern human relationship for a pocket-size CPU load, but nevertheless squealer the organisation for a long time.

Take around other await at Task 3. It solely runs every 100 msec, but it runs for xi msec. That's solely 11% CPU load. But xi msec is to a greater extent than than twice every bit long every bit Task 1's period! So that agency no affair what yous do, i time work three starts running, work 1 volition immature lady a deadline.  If yous desire to regard a unproblematic example, consider the next timeline:

Time 100:   Task 0 runs for 1 msec
Time 101:   Task three runs for xi msec
Time 112:   Task 0 tin laissez passer on the axe start running.  But it needed to run i time to a greater extent than betwixt times 105 as well as 110, as well as then it has already missed its deadline.

This work would occur regardless of CPU load. Even if Task three executes solely i time per day, every 24-hour interval Task 0 would immature lady its deadline. In fact, the longer the menses for Task 3, the less oftentimes the work volition occur as well as the harder it is going to hold out to uncovering this work inwards testing.  (Sure, around systems tin laissez passer on the axe occasionally immature lady a deadline. But yous at to the lowest degree desire to know that's going to occur to brand certain yous tin laissez passer on the axe pattern the organisation to hold out robust to a missed deadline. And for a security critical system, having a organisation that misses whatever deadlines due to a pattern flaw is a bad thought regardless of organisation robustness.)

In general, if whatever work has a compute fourth dimension longer than twice the menses of the fastest task, you're going to immature lady deadlines.  (A to a greater extent than precise formulation is if the gist of twice the compute fourth dimension of the fastest work summation the compute fourth dimension of the longest work is to a greater extent than than twice the menses of the fastest task, you'll immature lady deadlines.) Note that this is a necessary but non sufficient status for schedulability.

In pattern reviews I regard this work of depression CPU % but blocked high priority work frequently.  Very frequently. So don't allow it seize amongst teeth you!

Even if this isn't the instance it is nevertheless possible to immature lady deadlines amongst less than 100% CPU load, but that analysis takes a spell to explain, as well as then it volition receive got to hold off for around other posting..

If yous merely can't wait, the easy-to-explain (but tedious) way to banking venture check things is to lay out a timeline of when tasks volition execute using a spreadsheet, amongst i row per msec as well as starting amongst all tasks beingness ready to run at fourth dimension zero. Put downwardly when each work volition run every bit a serial of occupied cells inwards the timeline. Repeat until yous accomplish the to the lowest degree mutual multiple (LCM) of all the work periods. If they all fit, yous should hold out OK.  If not, yous demand to dig deeper into what's going on. (Note that this neglects the effects of jitter inwards work start times caused yesteryear race weather betwixt the timer ISR as well as the master copy loop if..else chain. So exercise attention amongst that analysis.) 


IMPORTANT, MUST BE READ...

Thank for your attention Top Two Mistakes In Main Loop Scheduling

my blog Top Two Mistakes In Main Loop Scheduling, Have a nice day.

Now you read article Top Two Mistakes In Main Loop Scheduling this permalink article is http://fairemirima.blogspot.com/2017/11/top-two-mistakes-in-main-loop-scheduling.html Thank you and Best regards. You Can read nice Tips below. It was always better to choose topics that interest you or in wich you at least have some knowledge about . When creating targeted internet copywriting , you have to stick with your strong points , or everyone will know it . Make a list of all of the things and or topics that you are interested in . . . How much do you know ? Can you tell it as a story ? That is The essence of writing for the web . You Have to know your subject well , or nobody will believe you it is always better to impress someone then upset them . When Writing Targeted Internet Copywriting , you have to choose your appropriate target group of customers . without a target group of customers , you could ramble on incessantly about random subjects for days on end with no essence of a final goal . You always have to keep in mind who your customers are and what they are looking for . . . . . . . . . IMPORTANT, MUST BE READ...

0 Response to "Top Two Mistakes In Main Loop Scheduling"

Post a Comment