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 VAA21843; Fri, 26 Mar 2004 21:04:56 +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 VAA22122 for ; Fri, 26 Mar 2004 21:04:55 +0100 (MET) Received: from mwinf0504.wanadoo.fr (smtp5.wanadoo.fr [193.252.22.26]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2QK4sHd010613 for ; Fri, 26 Mar 2004 21:04:54 +0100 Received: from morgana (ARennes-303-1-7-116.w80-14.abo.wanadoo.fr [80.14.144.116]) by mwinf0504.wanadoo.fr (SMTP Server) with ESMTP id 5D26A10003F9; Fri, 26 Mar 2004 21:04:54 +0100 (CET) Received: from david by morgana with local (Exim 4.30) id 1B6xZO-0000eD-R1; Fri, 26 Mar 2004 21:04:46 +0100 To: Christophe Raffalli Cc: caml-list@inria.fr Subject: Re: [Caml-list] Blocked thread ??? References: <4064043C.8080403@univ-savoie.fr> From: David MENTRE Organization: none Date: Fri, 26 Mar 2004 21:04:46 +0100 In-Reply-To: <4064043C.8080403@univ-savoie.fr> (Christophe Raffalli's message of "Fri, 26 Mar 2004 11:21:48 +0100") Message-ID: <87hdwbz869.fsf@linux-france.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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; caml-list:01 dmentre:01 raffalli:01 raffalli:01 univ-savoie:01 usr:01 usr:01 fork:01 forking:01 stdout:01 execvp:01 wexited:01 wexited:01 printf:01 printf:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 383 Hello Christophe, Christophe Raffalli writes: > 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). Are you sure it is not related to scheduling issues? On following slightly modified version of your program, I have added a "nice -n20" call and both codes seem to execute concurrently. But I agree with you that this behavior is quite strange: with "nice -n0" (i.e. normal priority) the calling process is stopped. Is your initial thread also doing CPU intensive job? Linux kernel 2.4 is known not to be very responsive in case a program is using all the CPU. This is one of the improvement in kernel 2.6. But I might be totally wrong. :) let _ = let command = "/usr/bin/nice" in let command_args = [| "/usr/bin/nice"; "-n20"; "/usr/bin/factor"; "12345678909999999999"; |] in let f () = print_string ("Calling POVRay: "^command); print_newline (); let pid = Unix.fork() in let status = if pid < 0 then ( print_string "error while forking"; print_newline (); flush stdout ); if pid = 0 then begin Unix.execvp command command_args; Unix.WEXITED(1) end else begin snd (Thread.wait_pid pid) 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 produced file"); print_newline () end; flush stdout in let t = Thread.create f () in Printf.printf ("doing other computation in initial thread"); for i = 1 to 2000 do Printf.printf "%i\n" i; flush stdout done; Printf.printf ("computation done in initial thread"); Thread.join t 61 Calling POVRay: /usr/bin/nice 62 [...] 1296 12345678909999999999: 3 3 3 3 79 1929313784966401 Calling POVRay on file produced file 1297 Yours, d. -- David Mentré ------------------- 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