Tcl Source Code

View Ticket
Login
Ticket UUID: 803370
Title: marked async handler not getting invoked
Type: Bug Created on: 2003-09-09 19:05:10
Submitter: ernfern Assigned to: kennykb
Subsystem: 01. Notifier Severity:
Priority: 5 Medium Last modified: 2003-12-16 16:25:42
Status: Open Closed by:
Resolution: None Closed on:
Version: obsolete: 8.4.4
Description:
HP-UX 10.20
HP aCC compiler

script is in Tk_Main.  An interrupt comes in and the 
interrupt handler calls Tcl_asyncMark() to mark a Tcl 
handler as ready to execute, but the handler does not 
get invoked until there are mouse events in the 
application's only window. 

I was expecting the handler to be invoked pretty much 
immediately as the application is pretty much idling at 
this point.
User Comments:
davygrvy added on 2003-09-10 05:58:47:
Logged In: YES 
user_id=7549

That's a know bug.  Tcl_ThreadAlert() called from 
Tcl_AsyncMark() does nothing when not compiled for threads 
on unix platforms.  This is the root of the problem.  It is a 
missing feature, that should have been there, in the unix 
notifier.

dkf added on 2003-09-10 20:02:02:
Logged In: YES 
user_id=79902

That's funny.  Is this caused by using unthreaded Tcl in a
threaded program?  Why isn't the select() call inside the
core of the event loop returning EINTR?  (Tcl doesn't set up
such interrupt handlers by default; there must be something
extra going on, and suspect that there might be a subtle bug
there instead.)

davygrvy added on 2003-09-10 20:09:34:
Logged In: YES 
user_id=7549

Whoop, me bad..

Tcl_ThreadAlert gets the notifier data and calls 
Tcl_AlertNotifier, but, as you can see, can't do jack:

void
Tcl_AlertNotifier(clientData)
    ClientData clientData;
{
#ifdef TCL_THREADS
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
clientData;
    Tcl_MutexLock(&notifierMutex);
    tsdPtr->eventReady = 1;
    Tcl_ConditionNotify(&tsdPtr->waitCV);
    Tcl_MutexUnlock(&notifierMutex);
#endif
}

If that can get implimented, Tcl_AsyncMark will have the 
ability to awaken the notifier.

dkf added on 2003-09-15 05:16:45:
Logged In: YES 
user_id=79902

Don't want to use threaded actions in a non-threaded lib;
that can have nasty side-effects in third-party stuff.

davygrvy added on 2003-09-15 06:05:46:
Logged In: YES 
user_id=7549

Well, do the logical thing then.  I didn't say to remove the 
#ifdef.

There are threaded actions happening.  Think about it.  Some 
OS thread called a signal handler that TclX might have 
trapped.  TclX then called Tcl_AsyncMark so it can't eval the 
script associated to it.  Now nothing happens because the 
notifier is waiting on select() yet Tcl_AlertNotifier does 
nothing to fulfil it's promise to break the wait.  Tcl_AsyncMark 
is promised to be the ONLY thread safe function in a single 
threaded core.  Sounds like just a technical challenge for a 
core hacker.  Not me though, I just do windows.

I remember talking with someone from IBM about their desire 
to have this 4 years ago.  His thought was to add an 
additional pipe to the select mask that's just for 
Tcl_AlertNotifier.

Is that plausable?

davygrvy added on 2003-12-16 15:22:55:
Logged In: YES 
user_id=7549

Can an additional pipe be used for select() that 
Tcl_AlertNotifier can write zero bytes to?

Passing to Kevin as I can't assist with this unix implimentation.

dkf added on 2003-12-16 16:25:42:
Logged In: YES 
user_id=79902

There are three configurations:
  1) Fully threaded
  2) Fully unthreaded
  3) Partially threaded (i.e. not threaded but with alerts
from other threads working)

Currently we only support 1 and 2 on Unix (POSIX signals do
not mix well with threads, unfortunately).  What we need is
a way to do option 3.  (Writing zero bytes has other
problems BTW; some Unixes - there was discussion of STREAMS
handling especially in relation to Expect a few years ago -
interpret that as closing the channel IIRC!  Writing a
single byte is better, and that's still unlikely to make the
pipe buffer overflow.)

Can't really help with the implementation.