Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / January 2007



Tip: Looking for answers? Try searching our database.

GetProcessAffinity on Quad core CPU

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 27 Jan 2007 13:42 GMT
Just wondering if anyone knows what the return values are for
GetProcessAffinity using a quad core CPU, using code below works fine
for dual core.

'/// Get CPU affinty for Process ID on dual core CPU ///

RetVal = GetProcessAffinity(PID)

Select Case RetVal
 Case 3
     Affinty = "0+1" 'CPU 0 and CPU 1
 Case 2
       Affinty = "1"   'CPU 1
 Case 1
       Affinty = "0"   'CPU 0
End Select

I don't have a quad yet but would like to get a head start on updating
one of my programs.

Thanks,
Ed
Mike D Sutton - 27 Jan 2007 21:41 GMT
> Just wondering if anyone knows what the return values are for
> GetProcessAffinity using a quad core CPU, using code below works fine
[quoted text clipped - 15 lines]
> I don't have a quad yet but would like to get a head start on updating
> one of my programs.

It simply returns a bit-mask of the processors:

Processor 1 = 0x1 = 0001b
Processor 2 = 0x2 = 0010b
Processor 3 = 0x4 = 0100b
Processor 4 = 0x8 = 1000b
Processor n = (2 ^ n)

So for four processors 1 through 4 you would use an affinity mask of 0x1 + 0x2 + 0x4 + 0x8 = 0xF.
Here's an old thread with some more information and examples on the call:
http://groups.google.co.uk/group/microsoft.public.vb.winapi/msg/83e88190612c4212
Hope this helps,

   Mike

- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
Ed - 28 Jan 2007 00:47 GMT
>Processor 1 = 0x1 = 0001b
>Processor 2 = 0x2 = 0010b
>Processor 3 = 0x4 = 0100b
>Processor 4 = 0x8 = 1000b

OK, I think it sunk in now! ;)

Cheers, (holding up coffee cup)
Thanks again,
Ed
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.