Skip to content

Instantly share code, notes, and snippets.

@etaf
Created May 8, 2020 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etaf/a5dde49815220f642acd242cde2b8ca3 to your computer and use it in GitHub Desktop.
Save etaf/a5dde49815220f642acd242cde2b8ca3 to your computer and use it in GitHub Desktop.
get_cpu_core_id.c
//...
#include <sys/syscall.h>
//...
int getCpuId() {
unsigned cpu;
if (syscall(__NR_getcpu, &cpu, NULL, NULL) < 0) {
return -1;
} else {
return (int) cpu;
}
}
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment