in reply to Time Allotments
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 | |
|
Re^2: Time Allotments
by alanonymous (Sexton) on Feb 20, 2012 at 06:59 UTC |