in reply to Time Allotments

ananonymous:

You've already gotten a few responses, but I can't keep from adding a couple things ;^)

For the question "is there time to insert another event?", I'd take a look at how much time is consumed in total:

$ cat pogo.pl #!/usr/bin/perl use strict; use warnings; use Number::Fraction; my %tasks = ( a=>4, b=>4, c=>4, d=>24, e=>24, f=>24, g=>100, h=>150, i=>150, j=> +150, k=>600 ); my $time = 0; for my $k (sort keys %tasks) { my $time_used = Number::Fraction->new( 1, $tasks{$k}); $time = $time + $time_used; print $time->to_string(), "\n"; } $ ./pogo.pl 1/4 1/2 3/4 19/24 5/6 7/8 177/200 107/120 539/600 181/200 68/75

So you definitely have time for 7 one-second events every 75 seconds, or 14 every 150 seconds, etc. Play with the factors, and you can figure out what's available.

Next comes the task of arranging them. Your task is perhaps a bit too "clean and academic" sounding. In your case, you can play with the factors and write a program to schedule all of them.

Back in a former life, when I did real-time systems, we'd just keep the tasks in a priority queue (implemented as a heap). Then, as we'd have time, we'd just pick off the next ready task. It's pretty simple, and a bit more flexible when your tasks have: (a) variable run times, and (b) a range of acceptable execution intervals. After you execute the task, just add its minimum interval to the current time and requeue it. When you pick off a task whose maximum interval has already been exceeded, generate a fault.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Time Allotments
by Marshall (Canon) on Feb 20, 2012 at 03:05 UTC
    I guess the classic story of a real-time priority based system ignoring lower priority tasks is described under: Apollo 11 Guidance Computer, look at the section titled "PGNCS trouble".

    The systems in use were very crude but thank goodness, there were some very smart folks programming this primitive stuff!

Re^2: Time Allotments
by alanonymous (Sexton) on Feb 20, 2012 at 06:59 UTC
    You are correct, this is quite 'clean and academic'. This actually refers to a broadcast datastream with different message timing requirements of 6 second chunks and I have simplified it greatly to get to the core of the problem, though the problem is definitely still intact.

    The tasks are all of equal length and can occur as frequently as I like, as long as that rule of max time interval between like events remains valid and true. The problem is that the system CAN'T (think dire consequences) exceed the maximum interval (ie, generating a vault), and it has to anticipate the sequence in advance to ensure the rules are ALWAYS met.