How to set CPU affinity in Wine or CrossOver?

8,085

Solution 1

Run the taskmgr.exe that comes with Wine, it allows you to set the affinity just like in Windows :).

I don't know how to set it permanently or automate setting it, though.

Possibly the same API that Windows uses for this task is present in Wine, which means that a Windows tool could be used for that task.

Edit:

I found a tool that does exactly that:

http://retired.beyondlogic.org/solutions/processutil/processutil.htm

Process -a name_of_exe 1 sets the affinity mask to processor 0.

Process -a name_of_exe 11 sets the affinity mask to processor 0 and 1.

... and so on.

See also:

http://en.wikipedia.org/wiki/Affinity_mask

Solution 2

Setting processor affinity on OS X is not supported. There is no such system call that wine could make to achieve this functionality. The related bug for this at WineHQ is appropriately closed as a WONTFIX (Bug 30480 - Setting CPU affinity doesn't work on Macs).

See also this related SU question: "How to set processor affinity on OS X?".

So while Jens' answer is a valiant effort, Wine will silently (or not so silently, depending on WINEDEBUG) discard those API calls to set affinity on a Mac.

The workaround commonly cited is to use one of Xcode's developer tools (like Instruments) to limit the total number of active cores available to the entire system. Not pretty, but it works. Instruments.app Preferences: General Pane

Solution 3

I think it's possible with the taskset command. Run wine like this:

taskset -c 0 wine program_name.exe

to get rid of debug-messages:

WINEDEBUG=-all taskset -c 0 wine program_name.exe

The "-c 0" part will set cpu affinity for core 1, "-c 1" would set it for core 2, etc. See "man taskset" for some more info.

Share:
8,085

Related videos on Youtube

hpy
Author by

hpy

Updated on September 17, 2022

Comments

  • hpy
    hpy almost 2 years

    There are some old games who don't like the multicore processors in today's computers. I am wondering if there is a way to set the CPU affinity for them to '1' under Wine or CrossOver? i.e. In a native Windows environment you would right click on the game's process in the Task Manager then set the affinity there.

    I've came across a program called RunFirst.exe, but can't figure out a way to run it, then the game in one command.

    Suggestions are appreciated. Thanks!

  • hpy
    hpy about 14 years
    Thanks for the tip, just tried it, but Mac OS X doesn't seem to come with taskset. Any other ideas?
  • VitorMM
    VitorMM over 6 years
    Wine crashes with a division by zero if I try to use Process.exe -a notepad.exe 1 while notepad is opened (as of Wine 2.16; also happens in Wine 1.7.7)