Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Inter-thread exceptions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-09-11 (20:43)
From: Dmitry Bely <dbely@m...>
Subject: Re: [Caml-list] Inter-thread exceptions
Xavier Leroy <> writes:

>> Nethertheless I think it's possible for network I/O, and even portable
>> enough (should work under pthreads/windows threads). Roughly the idea is
>> following:
>> 0. Create a global "interrupt" socket.
>> 1. Perform select() before  each blocking syscall, waiting for readability
>> of "interrupt" socket or the necessary state of "main" socket.
>> 3. If "main" socket was in the necessary state, do the syscall.
>> 4. If "interrupt" socket is readable, determine interrupt to which thread
>> is requested. If it's other thread, call sched_yield() for pthreads
>> (nothing under Windows) and return to (1)
> For one thing, not all blocking syscalls can be made non-blocking
> using select().  (Think opening a FIFO, for instance.)  Moreover, not
> all blocking syscalls are in C code that we control.  (Think
> gethostbyname(): it will do network I/O to query the DNS, but in a way
> that we don't control.)

Why not to make "non-blocking" as much C functions as possible using
select() technique and simply wait for the completion otherwise? For the
big class of problems this approach is enough. Another crazy idea --
rewrite Ocaml library using non-blocking (asynchronous) IO functions. All
modern OSes (including Windows) should support them.

- Dmitry Bely

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: