Created
January 25, 2021 21:40
-
-
Save r7vme/997a9a2a270b97da0bc96379cd85390c to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sysinfo.h> | |
#include <stdio.h> | |
#include <stdbool.h> | |
bool is_multicore_system(void) { | |
return (get_nprocs_conf() > 1) ? true : false; | |
} | |
// wrapper emulates single processor system | |
int __wrap_get_nprocs_conf() { return 1; } | |
int main(int argc, char *argv[]) | |
{ | |
is_multicore_system() ? printf("multicore system\n") : printf("singlecore system\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment