Community
cancel
Showing results for 
Search instead for 
Did you mean: 
garik4788
Beginner
43 Views

How is processor/cpu/thread affinity implemented at kernel level and hardware level??

I have been investigating on how a kernel ensures that a thread is locked to a processor using affinity.


Is there a special opcode for that locking?

or

there has to be issue slot management on the part of the kernel for each machine instruction fed into the pipeline?

Thanks.
0 Kudos
1 Reply
jimdempseyatthecove
Black Belt
43 Views

Thread affinity is performed in software. The application requests the operating system to restrict the scheduling to one or more processors usualy by way of a bit mask (but some O/S use other data structures to specify the desired affinity). Most O/S's have a bit mask of permitted processor(s) while some O/S's also have a preferred processor mask as well as other selection chriteria.

The restriction can be simple or complex depending on the O/S

Only processor(s) selected by bitmask (or list if list based)
Preference for processor(s) selected by bitmask (or list if list based)
Processor(s) sharing the same cache
Processor(s) NOT sharing the same cache
Processor(s) in the same package
Processor(s) NOT in the same package
Processor(s) in the same NUMA node
Processor(s) NOT in the same NUMA node
etc...

Reply