P
pkent
hi,
I'm sure someone must have solved this problem before, but I've
exhausted my searches of CPAN and the web - I bet there's a name for
this algorithm but I don't know what.
Imagine I have a program which has a number of independent, equally hard
(i.e. same CPU usage) jobs to do. Each job should be run every 5
minutes. What I want to do is spread those jobs out so that the "work"
is as evenly distributed as possible.
In that case it's obvious that I need to stagger each job by 5/n minutes
to spread them out most evenly. Easy.
But this is the hard part... what if some of my jobs have _different_
frequencies? I want to work out how to stagger each job so that, over
time, the work is still spread out on average and I minimize the number
of times when jobs occur together.
Visual example:
E.g. imagine 2 jobs that run every 4 minutes, and one that runs every 8.
One way of spreading them out would be this (each number is a different
job:
1...1...1...1...1...1...1...1...
...2...2...2...2...2...2...2...2.
....3.......3.......3.......3...
as opposed to
1...1...1...1...1...
2...2...2...2...2...
3.......3.......3...
I've been thinking about frequencies, harmonics, phases, highest common
factors, subsets of jobs with the highest common factor, differentials,
local minima, ... but is this soluble?
any help appreciated
P
P
I'm sure someone must have solved this problem before, but I've
exhausted my searches of CPAN and the web - I bet there's a name for
this algorithm but I don't know what.
Imagine I have a program which has a number of independent, equally hard
(i.e. same CPU usage) jobs to do. Each job should be run every 5
minutes. What I want to do is spread those jobs out so that the "work"
is as evenly distributed as possible.
In that case it's obvious that I need to stagger each job by 5/n minutes
to spread them out most evenly. Easy.
But this is the hard part... what if some of my jobs have _different_
frequencies? I want to work out how to stagger each job so that, over
time, the work is still spread out on average and I minimize the number
of times when jobs occur together.
Visual example:
E.g. imagine 2 jobs that run every 4 minutes, and one that runs every 8.
One way of spreading them out would be this (each number is a different
job:
1...1...1...1...1...1...1...1...
...2...2...2...2...2...2...2...2.
....3.......3.......3.......3...
as opposed to
1...1...1...1...1...
2...2...2...2...2...
3.......3.......3...
I've been thinking about frequencies, harmonics, phases, highest common
factors, subsets of jobs with the highest common factor, differentials,
local minima, ... but is this soluble?
any help appreciated
P
P