Problems? Is your data what you think it is? | |
PerlMonks |
Perl threads: using yield() and Time::HiRes usleep() in Linux/*nixby ait (Hermit) |
on May 10, 2009 at 15:33 UTC ( [id://763139]=perlquestion: print w/replies, xml ) | Need Help?? |
ait has asked for the wisdom of the Perl Monks concerning the following question:
Hello, fellow monks.
I am aware that the 5.8 threads model differs from system to system and compiling options so after reading the POD over and over, super-searching PM and reading up on several thread-threads, and actual code testing, I am still left with some doubt, and would greatly appreciate any experts here for their $0.02! First, I assume that the Linux, FreeBSD and most other Unix or Unix-like systems, except perhaps for Solaris, must have very similar threads implementations with the vanilla Perl 5.8.x offered in these platforms. I would assume that for example in most Linux systems, a vanilla Perl threads implementation will use, or compiled by default to use LWP aka Kernel Threads. Any in-depth comments for *nix OSs here very welcome. Second, and my actual question is that if using threads->yield _plus_ a millisecond delay with Time::HiRes is redundant, and if the snippet below is doing what I want: to yield at least 250 milliseconds of time to other threads before checking for the queue again. I am thinking that the yield is actually issuing a single no-op and really isn't doing much... but is the usleep() accomplishing what I need? Thridly, I would like to know if using Time::HiRes is thread safe, especially if I'm using Perl GTK2 which make everything a lot more fragile (not because of Perl but because of GTK-intrinsic threading flaws, which I have already learned to tame for the most part).
Thanks a bunch in advance, Alejandro Imass
Back to
Seekers of Perl Wisdom
|
|