From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA00100; Wed, 11 Sep 2002 22:43:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA00388 for ; Wed, 11 Sep 2002 22:43:01 +0200 (MET DST) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g8BKh0113997 for ; Wed, 11 Sep 2002 22:43:00 +0200 (MET DST) Received: (from uucp@localhost) by relay.rinet.ru (8.11.6/8.11.6) with UUCP id g8BKgvY27553 for caml-list@inria.fr; Thu, 12 Sep 2002 00:42:57 +0400 (MSD) X-Envelope-To: caml-list@inria.fr Received: from dialin1.stormoff (ROVER1) [192.168.0.129] by stormoff with esmtp (Exim 3.12 #1 (Debian)) id 17pEJz-0002BJ-00; Thu, 12 Sep 2002 00:42:48 +0400 X-Comment-To: Xavier Leroy To: caml-list@inria.fr Subject: Re: [Caml-list] Inter-thread exceptions References: <20020903164851.A26567@kruuna.Helsinki.FI> <20020905133052.C5343@pauillac.inria.fr> <20020909161527.C1781@pauillac.inria.fr> From: Dmitry Bely Date: Thu, 12 Sep 2002 00:41:35 +0400 In-Reply-To: <20020909161527.C1781@pauillac.inria.fr> (Xavier Leroy's message of "Mon, 9 Sep 2002 16:15:27 +0200") Message-ID: User-Agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.4 (Common Lisp (Windows [3]), i586-pc-win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners