diff options
author | kwolekr <mirrorisim@gmail.com> | 2013-02-21 17:44:14 -0500 |
---|---|---|
committer | kwolekr <mirrorisim@gmail.com> | 2013-02-25 23:08:41 -0500 |
commit | 60e6284f30d31e11c1a464d9a8b3c5c392ceb3f0 (patch) | |
tree | 20fe2138ce254232e369c20482a39c5e0da17450 /src/porting.h | |
parent | 67c59645ecd76cbf7a8186d0850ab5950e9ea22a (diff) | |
download | minetest-60e6284f30d31e11c1a464d9a8b3c5c392ceb3f0.tar.gz minetest-60e6284f30d31e11c1a464d9a8b3c5c392ceb3f0.tar.bz2 minetest-60e6284f30d31e11c1a464d9a8b3c5c392ceb3f0.zip |
Tune queue limits, some other adjustments
Diffstat (limited to 'src/porting.h')
-rw-r--r-- | src/porting.h | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/porting.h b/src/porting.h index 53aad6171..74ee97f88 100644 --- a/src/porting.h +++ b/src/porting.h @@ -46,8 +46,33 @@ with this program; if not, write to the Free Software Foundation, Inc., #else #include <unistd.h> #include <stdint.h> //for uintptr_t - + + #if defined(linux) || defined(__linux) + #define _GNU_SOURCE + #endif + + #include <sched.h> + + #ifdef __FreeBSD__ + #include <pthread_np.h> + typedef cpuset_t cpu_set_t; + #elif defined(__sun) || defined(sun) + #include <sys/types.h> + #include <sys/processor.h> + #elif defined(_AIX) + #include <sys/processor.h> + #elif __APPLE__ + #include <mach/mach_init.h> + #include <mach/thread_policy.h> + #endif + #define sleep_ms(x) usleep(x*1000) + + #define THREAD_PRIORITY_LOWEST 0 + #define THREAD_PRIORITY_BELOW_NORMAL 1 + #define THREAD_PRIORITY_NORMAL 2 + #define THREAD_PRIORITY_ABOVE_NORMAL 3 + #define THREAD_PRIORITY_HIGHEST 4 #endif #ifdef _MSC_VER @@ -109,6 +134,16 @@ void initializePaths(); int getNumberOfProcessors(); /* + Set a thread's affinity to a particular processor. +*/ +bool threadBindToProcessor(threadid_t tid, int pnumber); + +/* + Set a thread's priority. +*/ +bool threadSetPriority(threadid_t tid, int prio); + +/* Resolution is 10-20ms. Remember to check for overflows. Overflow can occur at any value higher than 10000000. |