From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Start a Windows process and get its text output Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <22cd779c-b1bb-4501-abfe-7b35c2dd7a7b@b2g2000yqi.googlegroups.com> Date: Sun, 7 Feb 2010 22:36:11 +0100 Message-ID: NNTP-Posting-Date: 07 Feb 2010 22:36:11 CET NNTP-Posting-Host: ce65a7a5.newsspool3.arcor-online.net X-Trace: DXC=g2^M`]f^79g9kIfcjg:0fdMcF=Q^Z^V3h4Fo<]lROoRa8kFi?`gc X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8958 Date: 2010-02-07T22:36:11+01:00 List-Id: 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