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 LAA17482; Fri, 26 Mar 2004 11:18:08 +0100 (MET) 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 LAA17296 for ; Fri, 26 Mar 2004 11:18:06 +0100 (MET) Received: from post.bourget.univ-savoie.fr (post.bourget.univ-savoie.fr [193.48.120.73]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2QAI5Hd026965 for ; Fri, 26 Mar 2004 11:18:06 +0100 Received: from univ-savoie.fr (d85.lama.univ-savoie.fr [193.48.123.85]) by post.bourget.univ-savoie.fr (8.12.3/jtpda-5.4) with ESMTP id i2QALgEK003569 ; Fri, 26 Mar 2004 11:21:42 +0100 Message-ID: <4064043C.8080403@univ-savoie.fr> Date: Fri, 26 Mar 2004 11:21:48 +0100 From: Christophe Raffalli User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] Blocked thread ??? X-Enigmail-Version: 0.83.3.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig8C1A01330C8E3565279A75CE" Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; raffalli:01 raffalli:01 univ-savoie:01 openpgp:01 2440:01 3156:01 3.07:01 printf:01 sprintf:01 aliasing:01 printf:01 sprintf:01 fork:01 execvp:01 wexited:01 X-Attachments: type="application/pgp-signature" name="signature.asc" name="signature.asc" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 369 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig8C1A01330C8E3565279A75CE Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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 --------------------------------------------- --------------enig8C1A01330C8E3565279A75CE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFAZARDSQDyWB/+xBwRAig1AJ9jYQ1qr7z3bC1CRoH3JtziTQCQSQCdGaRT IHiHJcpCoKy76tLTSaAyqqs= =+Tls -----END PGP SIGNATURE----- --------------enig8C1A01330C8E3565279A75CE-- ------------------- 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