Jiang Wu said:
 > 1. In UNIX, TclBlend uses a pipe with non-blocking IO to wake up the Tcl
 > event loop.  If there are multiple event loops in several threads, will 
a
 > single pipe based IO trigger all event loops to wake up?

In the threaded version of Tcl, there are two distinct types of event 
loops.  There is a single globally shared select loop 
(NotifierThreadProc).  This thread performs the select() system call on 
behalf of all threads in the system.  It has a single pipe that it 
includes in the select mask so other threads can wake the select thread up 
to force it to update its select mask.  Whenever it detects an event, it 
notifies only the threads that have specified interest in that file 
descriptor.  This typically only wakes up one thread since most of the 
time file descriptors are only owned by one thread.

The second type of loop is the notifier loop created by each thread that 
waits for events.  Each thread that uses the Tcl notifier APIs creates a 
separate event queue.  If the event queue becomes empty, the notifier 
thread blocks waiting for notification from the select loop (or a timeout).

So, with TclBlend, there should be one notifier loop per thread that 
contains an interpreter.  There should be exactly one select loop for the 
entire process.

 > 2. In Windows, a Win32 native window event is used to call 
Tcl_ServiceAll()
 > to trigger the Tcl event loop.  The same question applies, does
 > Tcl_ServiceAll() trigger all Tcl event loops to wake up?

In Windows, there is only one type of loop.  A separate Win32 window event 
loop is used for each thread.  The Tcl_ServiceAll() routine only affects a 
single thread's event queue.
 
 > 3. Currently, I am seeing a problem on Solaris, where the non-blocking 
pipe
 > used in TclBlend is triggering a busy loop on reading from the pipe.  
The
 > similar code in Tcl 8.3.1 for the event loop has a slightly different
 > implementation from that used in TclBlend with a comment about "reading 
only
 > 1 byte at a time to avoid some race condition".

I'm not sure what would be causing a busy loop.  Can you tell what it is 
looping on?  The basic procedure should be that one or more threads write 
a byte onto the pipe.  The select thread will read one byte per select() 
iteration.  The only way it could loop is if some thread was repeatedly 
writing to the pipe or if the select thread failed to consume data from 
the pipe.

--Scott


----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to