From: David MENTRE <dmentre@linux-france.org>
To: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Blocked thread ???
Date: Fri, 26 Mar 2004 21:04:46 +0100 [thread overview]
Message-ID: <87hdwbz869.fsf@linux-france.org> (raw)
In-Reply-To: <4064043C.8080403@univ-savoie.fr> (Christophe Raffalli's message of "Fri, 26 Mar 2004 11:21:48 +0100")
Hello Christophe,
Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr> 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é <dmentre@linux-france.org>
-------------------
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
prev parent reply other threads:[~2004-03-26 20:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-26 10:21 Christophe Raffalli
2004-03-26 10:27 ` [Caml-list] " Christophe Raffalli
2004-03-26 20:04 ` David MENTRE [this message]
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=87hdwbz869.fsf@linux-france.org \
--to=dmentre@linux-france.org \
--cc=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