X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/edde8f7fbc1b74a81551bf9eb7bac1935b999296..53cde8dfb94134348e908b3c2845200ffc582dc7:/src/xbt/xbt_os_thread.c diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index a53dfc90dd..8c9f2b02ca 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -137,7 +137,11 @@ void xbt_os_thread_mod_postexit(void) int xbt_os_thread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) { +#ifdef WIN32 + THROW_UNIMPLEMENTED; //pthread_atfork is not implemented in pthread.h on windows +#else return pthread_atfork(prepare, parent, child); +#endif } static void *wrapper_start_routine(void *s) @@ -1159,6 +1163,33 @@ void xbt_os_sem_get_value(xbt_os_sem_t sem, int *svalue) #endif + +/** @brief Returns the amount of cores on the current host */ +int xbt_os_get_numcores(void) { +#ifdef WIN32 + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; +#elif MACOS + int nm[2]; + size_t len = 4; + uint32_t count; + + nm[0] = CTL_HW; nm[1] = HW_AVAILCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + + if(count < 1) { + nm[1] = HW_NCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + if(count < 1) { count = 1; } + } + return count; +#else + return sysconf(_SC_NPROCESSORS_ONLN); +#endif +} + + /***** reentrant mutexes *****/ typedef struct xbt_os_rmutex_ { xbt_os_mutex_t mutex;