From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8C790BB91 for ; Fri, 21 Jan 2005 02:16:16 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0L1GGoe019286 for ; Fri, 21 Jan 2005 02:16:16 +0100 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 CAA19644 for ; Fri, 21 Jan 2005 02:16:14 +0100 (MET) Received: from miritek.com (v30-53.icu.ac.kr [210.107.130.53] (may be forged)) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0L1GCP3019283 for ; Fri, 21 Jan 2005 02:16:13 +0100 Received: from [192.168.1.21] (v30-54.icu.ac.kr [210.107.130.54] (may be forged)) by miritek.com (8.9.3/8.9.3) with ESMTP id KAA04229; Fri, 21 Jan 2005 10:30:40 +0900 Message-ID: <41F057D2.4020407@compiler.kaist.ac.kr> Date: Fri, 21 Jan 2005 10:16:02 +0900 From: SooHyoung Oh User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: ko-kr, ko, en-us, en MIME-Version: 1.0 To: Markus Mottl Cc: OCaml Subject: Re: [Caml-list] C-threads & callbacks References: <20050120182313.GB4919@quant3.janestcapital.quant> In-Reply-To: <20050120182313.GB4919@quant3.janestcapital.quant> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 41F057E0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41F057DC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; compiler:01 caml-list:01 ocaml:01 markus:01 mottl:01 interfacing:01 threads:01 ocaml-code:01 ocaml-code:01 ocaml:01 mutexes:01 error-prone:01 afaik:01 markus:01 caml-list:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: I'v resolved the same problem using TCP/IP communication between Ocaml thread and C thread. Markus Mottl 쓴 글: >Hi, > >I'm currently interfacing a 3rd-party library that spawns threads >to execute callbacks. I would like those callbacks to be handled by >OCaml-code, but have run into some issues here. > >As it seems, it is not possible to run OCaml-code linked with thread >support while letting C-threads perform callbacks. This has already >been a topic on the list a while ago. > >I have two solutions in mind: the first one would involve pre-spawning >an OCaml-thread and pass data from C to OCaml through an OCaml-reference >exposed to C, protected by mutexes and condition variables. This seems >pretty ugly, because it's error-prone and also involves a considerable >amount of context-switching, which is bad for my application (very high >volume realtime data). > >The second solution would require setting up an OCaml thread descriptor >for the currently executing C-thread. However, AFAIK this solution >cannot be implemented without fiddling with the implementation of the >OCaml-runtime, because some global variables for thread-handling are not >exposed to user code (i.e. "static"). It would be great if the thread >implementation offered functions allowing users to have their C-threads >"migrate" to OCaml. > >Does anybody know of another elegant and efficient solution for this >problem that does not require hacking the OCaml-runtime? > >Best regards, >Markus > >_______________________________________________ >Caml-list mailing list. Subscription management: >http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >Archives: http://caml.inria.fr >Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >Bug reports: http://caml.inria.fr/bin/caml-bugs > > >