Overview
| Artifact ID: | 31ed9c318c81536e2651e4b1288c8e7013972f54 |
|---|---|
| Ticket: | 3547994fffffffffffffffffffffffffffffffff
Modernize Windows channel drivers |
| User & Date: | twylite on 2012-07-25 03:26:51 |
Changes
- icomment:
@ David: moving all IO to overlapped is a problem because of the impedence mismatch between the Windows and Tcl eventing models. Tcl expects to live in a level triggered world. Windows is primarily edge triggered. That's why we have these worker threads that turn the edge trigger into a level that a Tcl event check proc can handle. > If I remember correctly, the main notifier uses an alertable mechanism that > supports calling a CompletionRoutine from it should that direction be > chosen. > See MsgWaitForMultipleObjectsEx() with MWMO_ALERTABLE flag. Mmm. Off-topic, but I'll bite: You can't actually use OVERLAPPED and completion routines, because of the impedence mismatch. In *nix you call select() to see if something is readable or writable. In Windows you perform an overlapped ReadFile() or WriteFile() and get notified of the result. IoCompletion ports don't provide a way to notify you that a stream has pending data. If you want level-based notification in Windows you either use select() (as in *nix, with very slow pipes as the alert mechanism), or you use WSAAsyncSelect (similar to select() but you wait on events with WaitForMultipleObjects), or you use WSAEventSelect which sends messages to a widows in a thread. The former two have limited scalability - in particular WaitForMultipleObjects has a limit of 64 objects and MS recommends breaking larger wait lists into groups and worker threads. So I did a quick port of tclWinSock.c to use the notifier window instead of the cothread window. Works marvellously, until you want to simulate blocking IO at the Tcl level. At that point you need to wait on an event, without blocking window messages from WSAEventSelect (which will set the event), with blocking any window messages that could cause the blocking IO to be non-modal. E_CANT_DO. It _should_ be possible to rework the Windows notifier, sockets and pipe code to use just one additional thread per process. It's a major change. It's all great right until you want to do blocking (from Tcl's perspective) socket IO in the main thread. Then you can't use MsgWaitForMultipleObjectsEx()
- login: "twylite"
- mimetype: "text/plain"
- username: "twylite"