marked async handler not getting invoked
Open803370ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-09-09 19:05:10
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.
davygrvyplain2003-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.
davygrvy Ticket [803370ffff]: 1 change
[History diff]2003-09-10 06:10:34
dkfplain2003-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.)
davygrvyplain2003-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(¬ifierMutex);
tsdPtr->eventReady = 1;
Tcl_ConditionNotify(&tsdPtr->waitCV);
Tcl_MutexUnlock(¬ifierMutex);
#endif
}
If that can get implimented, Tcl_AsyncMark will have the
ability to awaken the notifier.
dkfplain2003-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.
davygrvyplain2003-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?
dgp Ticket [803370ffff]: 1 change
[History diff]2003-11-13 05:19:20
davygrvyplain2003-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.
dkfplain2003-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.
Log in (anonymous is fine) to add a comment.