Scripts/ProcessorAffinity

From J Wiki
Jump to: navigation, search

Notes

Here is a quick example of setting Processor Affinity on Windows 7.

Usage

setproc 0
test ''
NB. look at Task Manager Performance tab.
NB. JBreak
setproc 1
test ''
NB. look at Task Manager Performance tab.
NB. JBreak

Download script: affinity.ijs

NB. Processor Affinity

script '~system\main\dll.ijs'

GetCurrentProcess=: >@{.@('kernel32 GetCurrentProcess i'&(15!:0))
GetProcessAffinityMask=: ('kernel32 GetProcessAffinityMask i i * *'&(15!:0))
SetProcessAffinityMask=: ('kernel32 SetProcessAffinityMask i i i'&(15!:0))

setproc =: 3 : 0
'rc tid pam sam'=.GetProcessAffinityMask (GetCurrentProcess'');(,2-2);(,2-2)
ppr=.bx (8#2)#: sam
SetProcessAffinityMask tid;0{,(8#2)#. 1 (y{,ppr) }8#0
)


test=: 3 : 0
while. 1 do.
a=.1+1
end.
)

Footnotes

<<FootNote>>


Contributed by David Mitchell