I'm going to be writing a multi-threaded shared memory messaging system for ultra high-volume message delivery between processes. The messages will originate from the worker threads of a web-server. I'd like to exploit the CPU cache locality that cores on the same CPU share. So that when I wake up a worker thread on the receiving end of this IPC system, I wake up a thread on the same CPU.
I need for Linux (prefferably POSIX in genaral) and windows the API calls and the bitmasking I need to do to extract the information which will let me classify the executing thread-id -- from the context of said thread -- using the following struct:
struct thread_core_id
{
uint16_t cpu_Id;
uint16_t core_Id;
};
Functions for both platforms will be greatly appreciated. I'm hoping this can be done without system calls -- i.e., context-switches.
-- edit --
I'm focusing on x86 at the moment, but other architectures would be useful as well.