caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Blocked thread ???
Date: Fri, 26 Mar 2004 11:21:48 +0100	[thread overview]
Message-ID: <4064043C.8080403@univ-savoie.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]


I use the piece of code at the end of the mail to launch an external 
command from a thread. The problem is that despite the fact execpv is 
called from a newly created thread, the original thread does not get any 
CPU until the
command stop computing (but the command is still running waiting for a 
click).

I tried to use Sys.command and also Sys.command "... &" with no extra 
thread creation, but the same happend. I think I am missing somthing ...

I am using ocaml 3.07pl2 and should not have to use the obsolete 
threadUnix ...

Remark: the thread excuting the piece of code below is itself a 
secondary thread (not the main thread). I do not know if this is important.

   let command = "povray" in
   let command_args =
     [|
       "povray";
       "+SP8"; "+FN8"; "+P";
       Printf.sprintf "+A%f" !pov_aliasing;
       Printf.sprintf "+W%d" pixels;
       Printf.sprintf "+H%d" (int_of_float (ratio *. (float) pixels));
       Printf.sprintf "+O%s" out_filename;
       in_filename
     |]
   in
   let f () =
     print_string ("Calling POVRay: "^command);
     print_newline ();
     let pid = Unix.fork() in
     let status =
       if pid = 0 then begin
	Thread.yield ();
	Unix.execvp command command_args;
	Unix.WEXITED(1)
       end else  begin
	Thread.yield ();
	snd (Unix.wait())
       end;
     in
     if status <> Unix.WEXITED(0) then begin
       print_string ("execution of \""^command^"\" failed.");
       print_newline ();
     end else begin
       print_newline ();
       print_newline ();
       Printf.printf ("Calling POVRay on file %s produced file %s")
	in_filename out_filename;
       print_newline ()
     end
   in
   ignore (Thread.create f ())

-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature
---------------------------------------------

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

             reply	other threads:[~2004-03-26 10:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-26 10:21 Christophe Raffalli [this message]
2004-03-26 10:27 ` [Caml-list] " Christophe Raffalli
2004-03-26 20:04 ` [Caml-list] " David MENTRE

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=4064043C.8080403@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --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).