From: <le...@us...> - 2004-03-13 19:49:00
|
Update of /cvsroot/rtk/rtk/src/core/platform/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22805/src/core/platform/linux Modified Files: Thread.cpp Log Message: Added implementation (GNU/Linux) for SetPriority, GetPriority and GetID methods. Index: Thread.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/Thread.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Thread.cpp 9 Mar 2004 15:13:48 -0000 1.3 --- Thread.cpp 13 Mar 2004 19:40:08 -0000 1.4 *************** *** 88,97 **** int Thread::GetPriority() const { ! return -1; } int Thread::SetPriority(int priority) { ! return -1; } --- 88,116 ---- int Thread::GetPriority() const { ! pthread_t my_tid = pthread_self(); ! int policy; ! struct sched_param sp; ! (void) pthread_getschedparam(my_tid, &policy, &sp); ! return sp.sched_priority; } int Thread::SetPriority(int priority) { ! /* ! Linux allows the static priority value range 1 to 99 for SCHED_FIFO and ! SCHED_RR and the priority 0 for SCHED_OTHER. Since we are using default ! scheduling policy ! */ ! pthread_t my_tid = pthread_self(); ! int policy; ! struct sched_param sp; ! (void) pthread_getschedparam(my_tid, &policy, &sp); ! sp.sched_priority = priority; ! (void) pthread_setschedparam(my_tid, policy, &sp); ! } ! ! unsigned long GetId() ! { ! return pthread_self(); } |