Invoking External Batch Program on Multiple Core Machine

  • Thread starter Thread starter Luc The Perverse
  • Start date Start date
L

Luc The Perverse

Hello! You may remember me as the guy who's trying to learn C# and using
that old version 2003 of visual studio. (Although free version of command
line .NET compiler is available, so if some new feature would greatly
simplify my life, then I am not opposed)

I currently have an application that is single threaded that does batch work
(you pass it a file in the command line, it runs for 2-45 minutes and spits
out another file). I do not own the application and do not know what it is
written in.

This is very annoying since I have a dual core machine and would like to get
my work done as quickly as possible.

Is there a way to invoke a foreign application from C# to run on a specified
core? (If so, can you point me to an example?)

Right now we do our work, click "compile" and then wait. Eventually I would
like to try to implement some form of distributed computing on all our
office computers, so that someone needing to compile 4-5 items can occupy
the same number of idle cores accross the network.

To implement this I want to make a generic C# workhorse program that waits
around for work, occupies all cores until the work is done and returns the
results as soon as possible. I'm hoping that through smart use of
inheritance, I can make the differences between the distributed client and
the local client as little as possible.

Note: I have deliberately excluded details on what the compilation is for,
just in case my employer would have a problem with it (even though I doubt
they would).
 
Hello! You may remember me as the guy who's trying to learn C# and using
that old version 2003 of visual studio. (Although free version of
command line .NET compiler is available, so if some new feature would
greatly
simplify my life, then I am not opposed)

A free version of the *IDE* is available, not just the command line
compiler. You should upgrade, VS 2005 is very nice (I haven't used 2003,
but I have a friend who is using it now and every time I mention "well, VS
does this for me" he always finds himself saying "really? VS 2003 doesn't
do that"...I gather it's a pretty significant upgrade, and frankly I was
surprised at how much was left usable in the Express version, considering
it's free).
I currently have an application that is single threaded that does batch
work (you pass it a file in the command line, it runs for 2-45 minutes
and spits out another file). I do not own the application and do not
know what it is written in.

This is very annoying since I have a dual core machine and would like to
get my work done as quickly as possible.

So long as you remember that "dual core" does not mean "dual hard drive"
or "dual RAM". :) Depending on what that application is actually doing,
you may or may not realize benefits by having it run in the background
while you try to get something else done.
Is there a way to invoke a foreign application from C# to run on a
specified core? (If so, can you point me to an example?)

You can use the Process class to start a new process with a specific
command, and you can even set the ProcessorAffinity on the class instance
to control what CPUs it runs on. However, why would you want to set a
specific CPU? Windows is smart enough to distribute the workload fairly
across whatever CPUs are available. There's no need to assign the process
to a specific one.
Right now we do our work, click "compile" and then wait. Eventually I
would like to try to implement some form of distributed computing on all
our
office computers, so that someone needing to compile 4-5 items can occupy
the same number of idle cores accross the network.

The idea is sound. So sound, in fact, that I'm pretty sure I've read of
implementations that already exist to do this sort of thing. I think
there are even general-purpose solutions that you might be able to use
off-the-shelf. That said, depending on what exactly you're trying to do,
it may not be very hard to do it. Use some sort of peer-to-peer
architecture to control workload requests (.NET remoting? Socket? WCF?
Whatever...), run the process (capturing the output if you like).

Just keep in mind the caveat I mentioned at the outset: just because a CPU
core is available, that doesn't mean that running a process on the
computer won't impact whatever work someone else is already doing on the
computer.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top