I have just wrote a quick task manager-like-app that shows you running processes and the threads and affinity etc but i have a problem, on all of the processes it returns that the process affinity is 3?? (i have a dual core)

Why would it return 3?

Recommended Answers

All 3 Replies

It is the default value : 2^N-1 where N is the number of processors.
Each processor is represented by a bit. So 3 would mean you have 2 processors active.

Ah yes
so would this code work?

int affinity = p.ProcessorAffinity.ToInt32() - 1;
                            if (af < 1)
                            {
                                affinity = affinity + 1;
                            }

Affinity is to my knowledge mostly used to assign a certain thread to a certain processor.
If you test for af<1 it would mean your are testing for zero processors. Affinity are bits, so in this case they can be 1, 2 or 3.
Meaning processor 1 ,processor 2 or both.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.