Setting Processor Affinity

View: New views
10 Messages — Rating Filter:   Alert me  

Setting Processor Affinity

by IanQ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there a way via batch to set a program's processor affinity so that
the program starts up using whatever cpu I want? I was kind of hoping
the 'start' command would allow this, but it only sets priority.

ie: I want via batch to have Firefox start up using only cpu 1.

I searched and searched and came across a little program called
affinity.exe, but what I don't like is that this app leaves it's
command window open after loading the app I wanted loaded, meaning if
I execute what I stated above, I get Firefox open, but also am stuck
with a command window that needs to be closed manually.

Thx




Re: Setting Processor Affinity

by foxidrive-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 09 Jan 2008 00:15:17 -0000, "Ian" <iqyahoo@...> wrote:

>Is there a way via batch to set a program's processor affinity so that
>the program starts up using whatever cpu I want? I was kind of hoping
>the 'start' command would allow this, but it only sets priority.
>
>ie: I want via batch to have Firefox start up using only cpu 1.
>
>I searched and searched and came across a little program called
>affinity.exe, but what I don't like is that this app leaves it's
>command window open after loading the app I wanted loaded, meaning if
>I execute what I stated above, I get Firefox open, but also am stuck
>with a command window that needs to be closed manually.
>
>Thx

Can you use affinity.exe in a batch file and use the EXIT keyword as the last
line?



Re: Setting Processor Affinity

by IanQ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nope, the batch command window closes, but the command window for Affinity.exe stays open.

  ----- Original Message -----
  From: foxidrive
  To: batchworld@...
  Sent: Wednesday, January 09, 2008 00:06
  Subject: Re: [BATCH WORLD] Setting Processor Affinity


  On Wed, 09 Jan 2008 00:15:17 -0000, "Ian" <iqyahoo@...> wrote:

  >Is there a way via batch to set a program's processor affinity so that
  >the program starts up using whatever cpu I want? I was kind of hoping
  >the 'start' command would allow this, but it only sets priority.
  >
  >ie: I want via batch to have Firefox start up using only cpu 1.
  >
  >I searched and searched and came across a little program called
  >affinity.exe, but what I don't like is that this app leaves it's
  >command window open after loading the app I wanted loaded, meaning if
  >I execute what I stated above, I get Firefox open, but also am stuck
  >with a command window that needs to be closed manually.
  >
  >Thx

  Can you use affinity.exe in a batch file and use the EXIT keyword as the last
  line?



   

[Non-text portions of this message have been removed]


RE: Setting Processor Affinity

by Marc Peterson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I thought this might be possible using rundll32 and kernel32.dll, but now I
don't think so because you would need launch the process, open a handle to
the running process, then make the affinity change.  Trying to make the
affinity change with just the PID does not work.  It can be done this way in
VBA, but probably not with batch commands.

I would search for an alternative to affinity.exe; I remember seeing others.
Here's one:
http://www.appliedvisual.com/xcpu.htm

Later,
Marc

>   On Wed, 09 Jan 2008 00:15:17 -0000, "Ian"
> <iqyahoo@...> wrote:
>
>   >Is there a way via batch to set a program's processor
> affinity so that
>   >the program starts up using whatever cpu I want? I was
> kind of hoping
>   >the 'start' command would allow this, but it only sets priority.
>   >
>   >ie: I want via batch to have Firefox start up using only cpu 1.
>   >
>   >I searched and searched and came across a little program called
>   >affinity.exe, but what I don't like is that this app leaves it's
>   >command window open after loading the app I wanted loaded,
> meaning if
>   >I execute what I stated above, I get Firefox open, but
> also am stuck
>   >with a command window that needs to be closed manually.
>   >
>   >Thx


Re: Setting Processor Affinity

by IanQ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, xcpu does indeed set affinity without leaving a command window open, only problem with it is that it starts the application minimized.

Getting closer!


  ----- Original Message -----
  From: Marc Peterson
  To: batchworld@...
  Sent: Thursday, January 10, 2008 13:59
  Subject: RE: [BATCH WORLD] Setting Processor Affinity


  I thought this might be possible using rundll32 and kernel32.dll, but now I
  don't think so because you would need launch the process, open a handle to
  the running process, then make the affinity change. Trying to make the
  affinity change with just the PID does not work. It can be done this way in
  VBA, but probably not with batch commands.

  I would search for an alternative to affinity.exe; I remember seeing others.
  Here's one:
  http://www.appliedvisual.com/xcpu.htm

  Later,
  Marc

  > On Wed, 09 Jan 2008 00:15:17 -0000, "Ian"
  > <iqyahoo@...> wrote:
  >
  > >Is there a way via batch to set a program's processor
  > affinity so that
  > >the program starts up using whatever cpu I want? I was
  > kind of hoping
  > >the 'start' command would allow this, but it only sets priority.
  > >
  > >ie: I want via batch to have Firefox start up using only cpu 1.
  > >
  > >I searched and searched and came across a little program called
  > >affinity.exe, but what I don't like is that this app leaves it's
  > >command window open after loading the app I wanted loaded,
  > meaning if
  > >I execute what I stated above, I get Firefox open, but
  > also am stuck
  > >with a command window that needs to be closed manually.
  > >
  > >Thx



   

[Non-text portions of this message have been removed]


Re: Setting Processor Affinity

by foxidrive-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 10 Jan 2008 19:48:52 -0500, "IanQ" <iqyahoo@...> wrote:

>Well, xcpu does indeed set affinity without leaving a command window open, only problem with it is that it starts the application minimized.
>
>Getting closer!

Untested:

xcpu –a 1 –p 3 –c start "" /max "d:\lightwave\programs\lightwav.exe"


Another option is to use something like cmdow.exe to maximise the window after
it has been started.



Re: Setting Processor Affinity

by IanQ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Great idea, one change as don't need the double quotes:

xcpu -a 1 -p 3 -c start /max "d:\lightwave\programs\lightwav.exe"

So to have it start with the window size as Normal, it's as simple as:

xcpu -a 1 -p 3 -c start "d:\lightwave\programs\lightwav.exe"

Thanks again!


  ----- Original Message -----
  From: foxidrive
  To: batchworld@...
  Sent: Thursday, January 10, 2008 20:00
  Subject: Re: [BATCH WORLD] Setting Processor Affinity


  On Thu, 10 Jan 2008 19:48:52 -0500, "IanQ" <iqyahoo@...> wrote:

  >Well, xcpu does indeed set affinity without leaving a command window open, only problem with it is that it starts the application minimized.
  >
  >Getting closer!

  Untested:

  xcpu -a 1 -p 3 -c start "" /max "d:\lightwave\programs\lightwav.exe"

  Another option is to use something like cmdow.exe to maximise the window after
  it has been started.



   

[Non-text portions of this message have been removed]


Re: Setting Processor Affinity

by Marc Peterson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here's another:
http://beyondlogic.org/solutions/processutil/processutil.htm

This one limits a process to the first processor:
http://www.activeplus.com/us/freeware/runfirst/

Set default processor affinity for an application:
http://jsifaq.com/SF/Tips/Tip.aspx?id=3542

I'm done,
Marc

--- In batchworld@..., "IanQ" <iqyahoo@...> wrote:
>
> Well, xcpu does indeed set affinity without leaving a command
window open, only problem with it is that it starts the application
minimized.
>
> Getting closer!


Re: Setting Processor Affinity

by BSOD :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am I missing something,

Is it not as straight forward as the following line in your batch

cmd /c affinity firefox


IanQ wrote:
Great idea, one change as don't need the double quotes:

xcpu -a 1 -p 3 -c start /max "d:\lightwave\programs\lightwav.exe"

So to have it start with the window size as Normal, it's as simple as:

xcpu -a 1 -p 3 -c start "d:\lightwave\programs\lightwav.exe"

Thanks again!


  ----- Original Message -----
  From: foxidrive
  To: batchworld@yahoogroups.com
  Sent: Thursday, January 10, 2008 20:00
  Subject: Re: [BATCH WORLD] Setting Processor Affinity


  On Thu, 10 Jan 2008 19:48:52 -0500, "IanQ" <iqyahoo@polarsong.com> wrote:

  >Well, xcpu does indeed set affinity without leaving a command window open, only problem with it is that it starts the application minimized.
  >
  >Getting closer!

  Untested:

  xcpu -a 1 -p 3 -c start "" /max "d:\lightwave\programs\lightwav.exe"

  Another option is to use something like cmdow.exe to maximise the window after
  it has been started.



   

[Non-text portions of this message have been removed]

Re: Setting Processor Affinity

by IanQ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nope, still leaves the command window open until the firefox app is closed.

xcpu does the trick, plus offers up priority scheduling should I ever need need it, whereas affinity.exe only set affinity.


  ----- Original Message -----
  From: BSOD
  To: batchworld@...
  Sent: Tuesday, January 22, 2008 08:02
  Subject: Re: [BATCH WORLD] Setting Processor Affinity



  Am I missing something,

  Is it not as straight forward as the following line in your batch

  cmd /c affinity firefox

  IanQ wrote:
  >
  > Great idea, one change as don't need the double quotes:
  >
  > xcpu -a 1 -p 3 -c start /max "d:\lightwave\programs\lightwav.exe"
  >
  > So to have it start with the window size as Normal, it's as simple as:
  >
  > xcpu -a 1 -p 3 -c start "d:\lightwave\programs\lightwav.exe"
  >
  > Thanks again!
  >
  >
  > ----- Original Message -----
  > From: foxidrive
  > To: batchworld@...
  > Sent: Thursday, January 10, 2008 20:00
  > Subject: Re: [BATCH WORLD] Setting Processor Affinity
  >
  >
  > On Thu, 10 Jan 2008 19:48:52 -0500, "IanQ" <iqyahoo@...>
  > wrote:
  >
  > >Well, xcpu does indeed set affinity without leaving a command window
  > open, only problem with it is that it starts the application minimized.
  > >
  > >Getting closer!
  >
  > Untested:
  >
  > xcpu -a 1 -p 3 -c start "" /max "d:\lightwave\programs\lightwav.exe"
  >
  > Another option is to use something like cmdow.exe to maximise the window
  > after
  > it has been started.
  >
  >
  >
  >
  >
  > [Non-text portions of this message have been removed]
  >
  >
  >

  --
  View this message in context: http://www.nabble.com/Setting-Processor-Affinity-tp14702544p15018163.html
  Sent from the Batch World mailing list archive at Nabble.com.



   

[Non-text portions of this message have been removed]

LightInTheBox - Buy quality products at wholesale price