no-can-do with cond_wait
the main loop MUST process other kind of events too
like painting & mouse clicking, which shouldn't block
behind my childthread .
 --> "A thread exited while other threads were running" type of error?
this aint my error. i get a different one , seems that some mystic variable
is still in scope :
smth like this
--- 1dc1a44 is not a hash at C:/Perl/site/lib/Tk/Widget.pm line 96 during
global destruction. ---
anyway , this is not a global concern.

should i lock the $clockstr before reading/writing it ?
in Java i didn't have to lock 'non-object' variables, the VM
did it for me, dunno about perl :(

ps. does anyone know a nicer way to sleep a bit , like 0.010-0.050 msec ?
the yield thing still kills the cpu dead but it at least let's some other
process make their moves, without it the program will almost hang an older
machine :( still a little sleep would be nicer

 Martin



#$%>-----Original Message-----
#$%>From: Elizabeth Mattijsen [mailto:[EMAIL PROTECTED]]
#$%>Sent: Monday, September 23, 2002 12:08 PM
#$%>To: Martin Roos; Perl-Ithreads
#$%>Subject: Re: Yippii , got it working, my first multithreaded tk app ;-)
#$%>
#$%>
#$%>At 12:02 PM 9/23/02 +0300, Martin Roos wrote:
#$%>>TU all for suggestions, the code looks pretty much
#$%>>ok now, throws a bogus error at the end but is
#$%>>generally ok , :)
#$%>
#$%>"A thread exited while other threads were running" type of error?
#$%>
#$%>
#$%>>                 threads->yield();
#$%>
#$%>In my (short) experience with threads programming, I have found
#$%>you should
#$%>avoid yield() as the plague, at least if you want to have any kind of
#$%>performance.  Why is it here?
#$%>
#$%>
#$%>># the child thread running loop
#$%>># updates the clock after every 1 sec
#$%>>sub clocker {
#$%>>         print "clocker starting \n";
#$%>>         while($running) {
#$%>>                 $clockstr = time();
#$%>>                 sleep(1);
#$%>>                 threads->yield();
#$%>>         }
#$%>>         print "child out \n";
#$%>>}
#$%>
#$%>Again, threads->yield().  You should look at cond_wait() and
#$%>cond_signal()
#$%>to have threads wait for something to happen (instead of
#$%>burning CPU with
#$%>yield()).
#$%>
#$%>
#$%>Liz
#$%>

Reply via email to