Search code examples
linuxpid

How to convert the processer number to 32 bit hexadecimal value


I am trying to assign a particular process to a particular CPU core. e.g $taskset -p 0x11 4106

I know from the example it is setting core 0 and 4 to "ON" and assigning it to PID 4106. Can someone help me understand the conversion from 0 and 4 to "0x11"


Solution

  • The formula is to raise 2 to the power of the number of each processor, then add them all up.

    For 0 and 4 we compute 20 and 24, giving 1 and 16, respectively.

    Their sum is 17, which in hexadecimal format is 0x11.