Thank you for pointing out that flaw,
gam3 - I had figured the timestamp was more granular than that. I will try something like you have suggested instead.
However, I'm thinking of several other options:
- Not requiring a program to remove itself from the queue. This will force the other programs to check to see if the process is still running, yes, but a process could always die, so, IMHO, I think the check_queue would always have to have a kill 0.
- Having a program signal the next process to wake up by sending an alarm and then bumping the sleep length up to a larger number. The wasted time between one process execution and another is less important than the wasted CPU cycles from waking up and checking on processes.
Update: I just thought of this... what if instead of the single queue file, or creating a file named PID.lock and sorting by modification time, I were to use Time::HiRes' gettimeofday and name the file gettimeofday.PID.lock (with the values in there of course)
Then... sorting the files numerically, should work, no?
--------------
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.