English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
C-threads & callbacks
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-01-21 (01:16)
From: SooHyoung Oh <shoh@c...>
Subject: Re: [Caml-list] C-threads & callbacks
I'v resolved the same problem using TCP/IP communication between
Ocaml thread and C thread.

Markus Mottl 쓴 글:

>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,
>Caml-list mailing list. Subscription management:
>Archives: http://caml.inria.fr
>Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>Bug reports: http://caml.inria.fr/bin/caml-bugs