A common way of doing this is to create a thread that is forced to run on the target core. If using Windows, for example, look at the SetThreadAffinityMask() function.
Or just use Linux NUMA API:
numa_run_on_node_mask() runs the current thread and its children only on nodes specified in nodemask. They will not migrate to CPUs of other nodes until the node affinity is reset with a new call to numa_run_on_node_mask(). Passing numa_all_nodes permits the kernel to schedule on all nodes again.