00001
00009
00010
00011
00012
00013 #ifndef __JTOP_SERVER_INCLUDE_OS_LINUX_H_
00014 #define __JTOP_SERVER_INCLUDE_OS_LINUX_H_
00015 #include <asm/param.h>
00016 #include <pthread.h>
00017 #include <stdlib.h>
00018
00019 #define OS_PRIO_STRING "Nice"
00020
00021 typedef int thread_t;
00022
00023 typedef long long cputime_t;
00024 typedef pthread_mutex_t os_mutex;
00025
00026 extern inline int os_thread_cmp(thread_t t1, thread_t t2);
00027 extern inline int os_thread_near(thread_t t1, thread_t t2);
00028 extern inline void os_mutex_init(os_mutex *mutex);
00029 extern inline void os_mutex_destroy(os_mutex *mutex);
00030 extern inline void os_mutex_lock(os_mutex *mutex);
00031 extern inline void os_mutex_unlock(os_mutex *mutex);
00032 extern inline int os_time2ms(cputime_t time);
00033 extern inline int os_time2us(cputime_t time);
00034
00035 extern inline int os_thread_cmp(thread_t t1, thread_t t2){
00036 return t1-t2;
00037 }
00038
00039
00040
00041 extern inline int os_thread_near(thread_t t1, thread_t t2){
00042 return abs(t1-t2)<10;
00043 }
00044
00045 extern inline void os_mutex_init(os_mutex *mutex){
00046 pthread_mutex_init(mutex, 0);
00047 }
00048
00049 extern inline void os_mutex_lock(os_mutex *mutex){
00050 pthread_mutex_lock(mutex);
00051 }
00052
00053 extern inline void os_mutex_unlock(os_mutex *mutex){
00054 pthread_mutex_unlock(mutex);
00055 }
00056 extern inline void os_mutex_destroy(os_mutex *mutex){
00057 pthread_mutex_destroy(mutex);
00058 }
00059
00060 extern inline int os_time2ms(cputime_t time){
00061 return time*(1000/HZ);
00062 }
00063
00064 extern inline int os_time2us(cputime_t time){
00065 return time*(1000000/HZ);
00066 }
00067
00068 #endif