Jump to content

All CPU Affinity except one

Recommended Posts

Hi, i have a program that use 100% of all Threads of my CPU.

It become impossible to do anything else on this machine when processing.

I wan't to disabled the affinity of the first and the second for that process.

I can find a lot of example to use the first and the second, like: 

;_WinAPI_SetProcessAffinityMask($hProc, 0x01) ;Set affinity for 1-st core
;_WinAPI_SetProcessAffinityMask($hProc, 0x02) ;Set affinity for 2-nd core
_WinAPI_SetProcessAffinityMask($hProc, 0x03) ;Set affinity for both cores

... but how to do the inverse?

My machine is 56 threads! 

Thank you for your help.



Share this post

Link to post
Share on other sites

What happens if you set the affinity to all but those?

i understand that you say it uses all, but i just mean, set affinity "on top" of it.


Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples


Share this post

Link to post
Share on other sites

Thank you for your interest.

I have 14 cores x 2 hyperthreaded, so 56 threads.

I wan't to disabled the first 4 threads of an running process.


It will be great if this script could work not depending of the maximum threads a machine have.

Because i would like to run on several machine that have different number of cores.

But everytime, i want the same thing: disabled the first 4 threads on a specific process.


I Hope it is clear...

Thank you for your help. 



Edited by kamesankamesan

Share this post

Link to post
Share on other sites

Ok, i understand now that 56 threads affinity is 72057594037927935  in decimal number.

But Autoit handle decimal number in 32bits.

So it can't set all cpu affinity...

max seem to be: 4294967295 (32 threads)


Any idea?


Edited by kamesankamesan

Share this post

Link to post
Share on other sites

Hmm, i'm trying a different way.... Correct me please if i'm wrong.

 0x00000000FFFFFFFF = 32 THREADS
 0x00000000FFFFFFFC = 32 THREADS -  first 2 THREADS  ?
 0x000000000000FFFF = 16 THREADS
 0x000000000000FFFC = 16 THREADS -  first 2 THREADS  ?
 0x00000000000000FF = 8 THREADS
 0x00000000000000FC = 8 THREADS -  first 2 THREADS  ?

Edited by kamesankamesan

Share this post

Link to post
Share on other sites


Please stick to just the one thread - and certainly do not resurrect any more 9-year old ones.


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

Sorry to disturb you with my double post 

I tought it wasn't impolite because my problem is no more "all Cpu's affinity except one". I found the way.

But because i use the script from the 9 year old post, i tought it was better to warn there about the uncompatibility with more than 32 cores machine.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...