Simple augmentation of reader allows MS Graphics...

From: David McClain (
Date: Sun Feb 14 1999 - 20:37:17 MET

From: "David McClain" <>
To: "Liste CAML" <>
Subject: Simple augmentation of reader allows MS Graphics...
Date: Sun, 14 Feb 1999 12:37:17 -0700

It is well known that Win32 console mode I/O blocks the event loop for
graphics threads. A simple external augmentation of read() allows new OCAML
toplevels to perform Window Graphics, without recompiling or altering the
runtime system.

Microsoft has graciously named their I/O primitive "_read( )" so that we can
create our own "read( )" routine to intercept uses of it at link time,
substituting our own version that in turn calls the C runtime primitive
"_read( )" when it is more appropriate -- such as from another thread. This
allows up to pump message queues in the main thread, and to start up other
graphics threads without the problems normally encountered by a blocking
"read( )".

You can get some sample code at

This code includes the augmented "read( )" routine, a separate console
reader thread, and a separate graphics thread that puts up a simple window
with some imagery. This code can be compiled and used ahead of the C runtime
libraries in the link command of "ocamlmktop" to create new toplevels that
enable Win32 graphics.

David McClain
Sr. Scientist
Raytheon Missile Systems Co.
Tucson, AZ

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:19 MET