Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-12-28
18:16 • Ticket [2891362fff] child interp with time limit does not return with eval vwait... artifact: 28e5b6f32b user: dkf
17:07 • Closed ticket [2891362fff]. artifact: bfee652223 user: dkf
16:17 • Ticket [2891362fff]: 4 changes artifact: be9e100080 user: dkf
2009-11-05
07:13 • Ticket [2891362fff]: 4 changes artifact: dbafe2d681 user: ferrieux
2009-11-04
23:10 • Ticket [2891362fff]: 1 change artifact: d194239a3a user: dkf
23:10 • Ticket [2891362fff]: 4 changes artifact: 4a63e17bfc user: dkf
21:34 • Ticket [2891362fff]: 4 changes artifact: b9b40b7c0a user: ferrieux
21:15 • Ticket [2891362fff]: 2 changes artifact: 3aff0821a7 user: dkf
2009-11-03
16:16 • New ticket [2891362fff]. artifact: 3ef338a96c user: john13a

child interp with time limit does not return with eval vwait

Closed / Fixed2891362fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-11-03 16:16:28
I expect that a child interp returns after the time limit has been reached.

Short example (for tclsh)
interp create -safe test
test limit -seconds [clock add [clock seconds] 1 second]; test eval {vwait forever}
dkf Ticket [2891362fff]: 2 changes [History diff]2009-11-04 21:15:37
ferrieuxplain2009-11-04 21:34:33
Note that this limitation is documented in TIP #143: 
"... (with a few exceptions relating to event loop handling.) ..."

Questions to dkf:

 (1)  any blocking syscall, not just select(), has the problem. For select() we can solve the issue by forcing a suitable periodic wake-up (at C level for performance, at script level as a quick fix for the OP), but do we want that ?

 (2) if the answer to (1) is Yes, is there a one-size-fits-all value for the periodicity ? If not, maybe we'd need an extra script-level API to pass this value ([interp limit -granularity] being only a subsampling of that), so that (say) high-load apps could pass a longer select timeout...
dkfplain2009-11-04 23:10:49
At the moment, when there's a time limit set there will be a timer event (which does nothing) scheduled to go off at that point which will act as a wakeup call for the notifier.
dkf Ticket [2891362fff]: 1 change [History diff]2009-11-04 23:10:50
ferrieuxplain2009-11-05 07:13:58
Ah yes, but that's not implemented yet, right ?
dkfplain2009-12-28 16:17:48
Examining with a debugger (I hate doing that!) I find that limits are being checked, and that if the -granularity limit option is set to 1 then it all works.

The bug is therefore that, when doing a long-running operation, the ticker is preventing the trap from doing any good. (The issue is that Tcl_GetTime is relatively expensive as operations go; you don't want to be calling it frequently when running bytecode at speed. To see what I mean, [time] how long [::tcl::clock::seconds] takes; that's very close to a raw interface to the problem syscall.)
dkfplain2009-12-28 17:07:48
allow_comments - 1

Found the problem; needed to reset the granularity ticker when the timer event fires.
dkfplain2009-12-28 18:16:32
BTW, there's not much we can do about other blocking syscalls except to say "switch all channels given to slave interps into non-blocking mode and don't let them switch back". That covers I/O and timers are already handled in Tcl. I don't think we use any other blocking syscalls (the Thread package is something else, and it's outside my scope). File another bug if such an issue is uncovered.
Log in (anonymous is fine) to add a comment.