0

I need help to calculate Processor Affinity value

0 (0000) Not allowed (that would mean use no processors) 1 (0001) Use processor 1 2 (0010) Use processor 2 3 (0011) Use both processors 1 and 2 4 (0100) Use processor 3 5 (0101) Use both processors 1 and 3 6 (0110) Use both processors 2 and 3 7 (0111) Use processors 1,2 and 3 8 (1000) Use processor 4 

With 1, 2, 3 and result is 7. I wonder what formula is?

3
  • It cannot be 1,2 and 3 to result in 7, as 3 represents 1 and 2, so it should be 1,2,4 using binary OR which results in 0111 which is 7. Commented Feb 14, 2011 at 9:37
  • 2
    With 1, 2, 3 and result is 7. ?? Commented Feb 14, 2011 at 9:37
  • "3" is a position in this context, which is represented by '0100' in binary, which is 4 in decimal. Commented Feb 14, 2011 at 9:40

3 Answers 3

1

It seems to be a simple 4-digit binary number.

A 1 at the right-most position means 1, a 1 at the second position from the right means 2, at the 3rd it means 4 and at the 4th position from right (i.e. the first digit from left) it means 8. The total value is simply the sum of all those positions.

The basic idea (in pseudo-code, because we can't format formulas correctly here is):

totalValue for every digit at position i (counted from the right, starting with 0) totalValue = totalValue + 2^i*(digit at position i) 

For example 3 (0011) the value is 0x2^3 + 0x2^2 + 1*2^1 + 1*2^0 = 0 + 0 + 2 + 1 = 3

For example 4 (0100) the value is 0x2^3 + 1x2^2 + 0*2^1 + 0*2^0 = 0 + 4 + 0 + 0 = 4

Sign up to request clarification or add additional context in comments.

1 Comment

So how to calculate it for example: 3, 4?
0
Processor_Affinity := Use_processor_1 + Use_processor_2 + Use_processor_3 

Comments

0

So 1010; interpret it as:

0 at 1st position as OFF 1 at 2nd position as ON 0 at 3rd position as OFF 1 at 4th position as ON 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.