Created
May 8, 2020 11:55
-
-
Save etaf/a5dde49815220f642acd242cde2b8ca3 to your computer and use it in GitHub Desktop.
get_cpu_core_id.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
#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