Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

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

garik4788
Beginner
488 Views
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
Honored Contributor III
488 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...

0 Kudos
Reply