comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Start a Windows process and get its text output
Date: Sun, 7 Feb 2010 22:36:11 +0100
Date: 2010-02-07T22:36:11+01:00	[thread overview]
Message-ID: <wpc0x3pkkyyp$.1o1eu07x84jyu$.dlg@40tude.net> (raw)
In-Reply-To: f9bb0878-0c89-4590-bf82-e6597459214a@d27g2000yqn.googlegroups.com

On Sun, 7 Feb 2010 11:24:41 -0800 (PST), Hibou57 (Yannick Duch�ne) wrote:

> As it is the subject here : I've just checked at least with GNAT it
> work nice to create a task, invok a CreateProcess from this Ada task
> and then WaitForSingleObject with delay INFINITE on the process handle
> always in the same Ada task : other Ada task are still running
> normally (a protected object can then be used to tell any other task
> the process has terminated).

You can use WaitForSingleObject in order to determine if the object (like
the process) is signaled without waiting. (Do not forget to close the
object handle when you don't need it.)

> I was wondering about the cost of threads on Windows, as GNAT create
> Ada task as Windows thread (I suppose its the same for Janus and
> others, I hope to be honest). I just found there is a default
> allocated stack of 1M bytes, and nothing about the cost of task
> creation and task switch in CPU cycles (from a pure point of view,

The cost of switching depends on the processor. I remember that it was very
high for x86 in earlier times. I cannot tell if it is still so.

But I think you can measure it. Start several tasks incrementing a counter
in a loop. A Windows call Delay (0) should switch the task prematurely. Do
that each, say 100_000 increments (it must be shorter than 1ms, otherwise
Windows scheduler will intervene). Run this until the sum of counters
reaches some value. Do the same with one task. The time difference divided
by the number of switches is the task switching overhead.

> dropping any page fault and the like). If someone know a good source
> about it, it would be nice (this is to weigh up the choice to have an
> Ada task per process vs. a single Ada task managing multiple
> processes).

The latter will not work in most cases because of blocking I/O. Well, there
is overlapped I/O API under Windows, but you would need to rewrite all code
for this, and not all (a minority in fact) devices support overlapped I/O.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



      parent reply	other threads:[~2010-02-07 21:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-06 17:39 Start a Windows process and get its text output Gautier write-only
2010-02-06 18:12 ` Hibou57 (Yannick Duchêne)
2010-02-06 18:23 ` Pascal Obry
2010-02-06 19:21   ` Gautier write-only
2010-02-06 19:42 ` Jeffrey R. Carter
2010-02-06 21:01 ` Dmitry A. Kazakov
2010-02-07 17:54 ` Vadim Godunko
2010-02-07 19:24   ` Hibou57 (Yannick Duchêne)
2010-02-07 19:36     ` Hibou57 (Yannick Duchêne)
2010-02-07 20:35     ` Hibou57 (Yannick Duchêne)
2010-02-07 21:36     ` Dmitry A. Kazakov [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox