caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Niki Yoshiuchi <aplusbi@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Using C threads
Date: Thu, 3 Mar 2011 18:46:05 -0500	[thread overview]
Message-ID: <AANLkTikK7muD3EejjzSr+sn_CABvd-mEcvcQAM4Xr8XE@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=isE4rXdGy7-dJQYzCJ6EAepffWTBbiiK84-gM@mail.gmail.com>

My main program is in OCaml.  Thread.thread_initialize is only called
if you actually use the module in question.  I tested this with some
simple code:

main.ml: (ocamlc -c main.ml)

let _ = Printf.printf "Main\n"

test.ml: (ocamlc -c test.ml)

let _ = Printf.printf "Test\n"

test2.ml: (ocamlc -o test2.cma -a test2.ml)

let _ Printf.printf "Test2\n"

ocamlc test2.cma test.cmo main.cmo
./a.out
Test
Main

"Test2" never gets printed.

On Thu, Mar 3, 2011 at 6:38 PM, Dmitry Bely <dmitry.bely@gmail.com> wrote:
> On Fri, Mar 4, 2011 at 2:23 AM, Niki Yoshiuchi <aplusbi@gmail.com> wrote:
>> Yes, I have (you can't use caml_c_thread_register() without it).
>> However it appears that the flag doesn't run the code in the module.
>
> If you link your program as described in the manual:
>
> ocamlc -thread other options unix.cma threads.cma other files
> ocamlopt -thread other options unix.cmxa threads.cmxa other files
>
> Thread.thread_initialize should be called automatically by ocaml
> runtime during startup. If it's not called, something is broken in
> your system. Do you have the main program in Ocaml? If not, do you
> call caml_startup() from your C code?
>
> - Dmitry Bely
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


  reply	other threads:[~2011-03-03 23:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 21:56 Niki Yoshiuchi
2011-03-01 12:14 ` Dmitry Bely
2011-03-03 22:16   ` Niki Yoshiuchi
2011-03-03 23:03     ` Dmitry Bely
2011-03-03 23:23       ` Niki Yoshiuchi
2011-03-03 23:38         ` Dmitry Bely
2011-03-03 23:46           ` Niki Yoshiuchi [this message]
2011-03-04  0:17             ` Dmitry Bely
2011-03-04  9:21             ` xclerc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTikK7muD3EejjzSr+sn_CABvd-mEcvcQAM4Xr8XE@mail.gmail.com \
    --to=aplusbi@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).