Re: Algorithm: spreading out jobs/events in time





pkent wrote:
> hi,
>
[---]

> 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...
>

[---]

Hi pkent,

You could fire them all off, and have a semaphore for each task- kindof
like this;

use Win32::Semaphore;
.....
Win32::Semaphore::Create($Sem,1,1,"Task1Sem")||die &Error;
if($Sem) {
$Sem->wait();
##semaphore is now UP....
### do all Task1 work
...
##place semaphore flag down...
$Sem->Release(1,$last);
}
else {
die("ERROR Getting SEMAPHORE");
}

...Programmers typically use these for database operations, but it
should be applicable to your needs. You of course have to figure out
what the work-thresholds are for your needs; You might need to "hold"
on several semaphore-flags... in which case beware of deadlocks.

Do a perldoc on Win32::Semaphore for specs- Perl also has semaphores
for UNIX/Linux if that's your need, but I don't know what they're
called.

HTH-

kDot

.