c - CPU-Core thread classification Function -
i'm going writing multi-threaded shared memory messaging system ultra high-volume message delivery between processes. messages originate worker threads of web-server. i'd exploit cpu cache locality cores on same cpu share. when wake worker thread on receiving end of ipc system, wake thread on same cpu.
i need linux (prefferably posix in genaral) , windows api calls , bitmasking need extract information let me classify executing thread-id -- context of said thread -- using following struct:
struct thread_core_id { uint16_t cpu_id; uint16_t core_id; };
functions both platforms appreciated. i'm hoping can done without system calls -- i.e., context-switches.
-- edit --
i'm focusing on x86 @ moment, other architectures useful well.
for linux should able required information out of /proc/cpuinfo
, /sys/devices/system/cpu/cpu*/cache
, use sched_{s|g}etaffinity()
calls. take @ what every programmer should know memory, if haven't already, around section 5.3.
Comments
Post a Comment