Multi-Rate Main Loop Task Timing

Multi-Rate Main Loop Task Timing - Hallo gues welcome to my blog, you can read this article with title Multi-Rate Main Loop Task Timing, Happy reading

IMPORTANT, MUST BE READ... : Multi-Rate Main Loop Task Timing
Title : Multi-Rate Main Loop Task Timing

Read More


Multi-Rate Main Loop Task Timing

IMPORTANT, MUST BE READ...
In the past times yoke posts I've talked nigh how to construct a multi-rate chief loop scheduler in addition to the two biggest mistakes I tend to reckon amongst timing analysis. In this posting I'll roll upwards the theme (at to the lowest degree for now) past times describing how to create upwards one's heed whether a detail job inward a non-preemptive multi-rate organization is going to come across its deadlines.  The math gets pretty complex in addition to is pretty painful, in addition to thus I'll move an illustration in addition to hand the full general rules without trying to demonstrate the iterative math behind the method. At that, this posting volition own got to a greater extent than move to empathize completely than my green posts, but it's only a complex theme in addition to this isn't the house for an entire mass chapter worth of math. On existent systems you lot tin mostly produce the checking amongst a spreadsheet 1 time you lot empathize the technique.

Consider the next job set:

Task  Period  Compute  CPU Load 
 0       vii       2       28.6%
 1      10       2       20%
 2      20       iii       15%    
 3     101       five        5%
 4     199       iii        1.5%
         Total CPU Load  70.1%  (numbers rounded to nearest 0.1%)

If nosotros desire to honor out the worst instance answer fourth dimension for Task 2, nosotros demand to hold off at the next worst case:
  • All the tasks inward the job laid exceed away develop to run simultaneously. In practise this way that the organization timer is at goose egg or equal to the to the lowest degree mutual multiple of all periods
  • The most obnoxious job amongst priority lower than the job nosotros attention nigh sneaks inward in addition to starts running only earlier the highest priority job gets to run. (Generally this happens because that job got  a direct chances to start correct at the terminal minute earlier the counter ticked.)
  • All the tasks amongst higher priority run 1 or to a greater extent than times (based on their periods) earlier the job nosotros attention nigh runs. In full general about tasks volition run multiple times earlier our job gets a direct chances to run.
So for the illustration instance of Task #2, that means:
  • Identify Task #3 every bit the job amongst the largest compute fourth dimension from those tasks amongst a priority higher than Task #2.  Assume it starts running at fourth dimension goose egg because it snuck inward ahead of all the other tasks.
  • Because it is fourth dimension zero, all other tasks are develop to run starting at fourth dimension zero. But because Task #3 snuck inward first, all the other tasks are inward the run queue at fourth dimension zero.
Now nosotros produce an iterative calculation every bit follows, amongst each numbered mensuration beingness an iteration of run the highest queued priority job in addition to compute the novel organization fourth dimension when it ends.
  1. Start at fourth dimension 0 amongst Task iii running.
    - Tasks 0, 1, 2, four queue to run at fourth dimension zero.
    - Running Task iii takes us to fourth dimension five when Task iii completes.
    - At fourth dimension five tasks nevertheless queued are:  0, 1, 2, 4
  2. Time 5: run highest priority queued task: Task 0.
    - This runs for 2 msec, bringing us to fourth dimension 7.
    - At fourth dimension vii nosotros accomplish the Task 0 period, in addition to thus about other re-create of Task 0 queues to run.
    - At fourth dimension vii tasks nevertheless queued are: 0, 1, 2, 4
  3. At fourth dimension vii run highest priority queued task: Task 0.
    - This runs for 2 msec, bringing us to fourth dimension 9.
    - At fourth dimension nine tasks nevertheless queued are: 1, 2, 4
  4. At fourth dimension nine run highest priority queued task: Task 1.
    - This runs for 2 msec, bringing us to fourth dimension 11.
    - At fourth dimension 10 about other re-create of Task 1 is queued (note that nosotros own got missed the deadline for Task 1 since it should own got completed at fourth dimension 10, but ran until fourth dimension 11).
    - At fourth dimension eleven tasks nevertheless queued are: 1, 2, 4
  5. At fourth dimension eleven run highest priority queued task: Task 1.
    - This runs for 2 msec, bringing us to fourth dimension 13.
    - At fourth dimension xiii tasks nevertheless queued are: 2, 4
  6. At fourth dimension xiii run highest priority queued task: Task 2.
    - This runs for iii msec, bringing us to fourth dimension 16.
    - At fourth dimension xiv about other re-create of Task 0 is queued.
    - At fourth dimension xiv tasks nevertheless queued are: 0, 4.
  7. At fourth dimension sixteen Task #2 has completed, ending our analysis
We've computed the worst instance fourth dimension to consummate Task 2 is sixteen msec, which is less than its twenty msec period. So Task 2 volition come across its deadline. However, along the way nosotros noticed that fifty-fifty though the CPU is alone loaded to 70.1% Task 1 is going to lady friend its deadline.

Graphically, the higher upwards scenario looks similar this:


The bluish arrows demonstrate where tasks exceed away queued to run, in addition to the boxes demonstrate which job is running when.

To create upwards one's heed if your organization is schedulable you lot demand to repeat this analysis for every job inward the system. In this case, repeating it for Task 1 volition unwrap that Task 1 misses its deadlines fifty-fifty though the CPU is alone loaded at 70.1%.

In full general the technique is to assume the longest-running job (biggest compute time) amongst priority lower than yours starts running in addition to all other tasks queue at that same time. Then play out the sequence to reckon if you lot come across your deadline. There are a few notes on exceptional cases. The longest job amongst lower priority may vary depending on which job you lot are evaluating. For example, the longest lower priority job for Task #3 is non Task #3, but rather Task #4. And the lowest priority job doesn't own got a lower priority blocking task, in addition to thus when evaluating Task #4 you lot tin only assume it starts at fourth dimension goose egg (there is no initial blocker).  This tin move expressed every bit an iterative equation that has to move cycled until it converges. If you lot actually desire a math-based approach own got a hold off at the CAN functioning lecture slides inward my grad course, which is pretty much the same math. But trying to explicate the math takes a lot to a greater extent than words in addition to complicated typography than are practical inward a weblog entry.

If you lot honor out you lot are missing deadlines in addition to desire to develop it, at that spot are ii full general techniques that tin help:
  • Make whatsoever actually long-running depression priority job run shorter, mayhap past times breaking it upwards into multiple shorter tasks that move together, or that tin "yield" command dorsum to the chief loop every 1 time inward a piece during their execution in addition to selection upwards the side past times side fourth dimension they run where they left off. This volition trim down the length of the initial blocking number for all higher priority tasks.
  • Schedule tasks in addition to thus their periods evenly dissever each other (this volition termination inward the Least Common Multiple of all periods equals the largest period). This corresponds to the the approach of harmonic job periods discussed inward the existent fourth dimension scheduling chapter of my book. For non-preemptive tasking it volition NOT back upwards 100% CPU usage, but in all likelihood it volition brand worst instance latency better.

Notes for readers who desire to move thorough:
  • If you lot own got interrupts you lot own got to include the ISR contribution to CPU workload when doing this analysis. Doing in addition to thus tin larn a fleck tricky.  The existent fourth dimension scheduling chapter of my mass shows how to produce this for a single-rate chief loop scheduler.
  • It may move that you lot desire to resolve a province of affairs inward which the fastest job gets blocked for also long past times putting that faster job into an ISR. If you lot produce that, proceed it brusque in addition to don't forget that it nevertheless affects CPU workload. This approach is discussed for a single-rate chief loop scheduler, also inward the existent fourth dimension scheduling chapter of my book.
  • We don't include the electrical flow job inward the "most obnoxious" consideration because nosotros start past times assuming the organization volition come across deadlines where deadline = job period. Any detail job has to own got finished running earlier it tin run over again unless it misses its deadline. So a job can't self-block inward a organization that is schedulable.



IMPORTANT, MUST BE READ...

Thank for your attention Multi-Rate Main Loop Task Timing

my blog Multi-Rate Main Loop Task Timing, Have a nice day.

Now you read article Multi-Rate Main Loop Task Timing this permalink article is http://fairemirima.blogspot.com/2017/11/multi-rate-main-loop-task-timing.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 "Multi-Rate Main Loop Task Timing"

Post a Comment