diff --git a/gc/ogc/lwp.h b/gc/ogc/lwp.h index 81b8490b..cdb1a94f 100644 --- a/gc/ogc/lwp.h +++ b/gc/ogc/lwp.h @@ -118,6 +118,15 @@ BOOL LWP_ThreadIsSuspended(lwp_t thethread); lwp_t LWP_GetSelf(void); +/*! \fn s32 LWP_GetThreadPriority(lwp_t thethread) +\brief Get the priority of the given thread. +\param[in] thethread handle to the thread context whos priority should be returned. If NULL, the current thread will be taken. + +\return 0 on success, <0 on error +*/ +s32 LWP_GetThreadPriority(lwp_t thethread); + + /*! \fn void LWP_SetThreadPriority(lwp_t thethread,u32 prio) \brief Set the priority of the given thread. \param[in] thethread handle to the thread context whos priority should be changed. If NULL, the current thread will be taken. diff --git a/libogc/lwp.c b/libogc/lwp.c index d363838d..fb3a7c07 100644 --- a/libogc/lwp.c +++ b/libogc/lwp.c @@ -265,6 +265,22 @@ lwp_t LWP_GetSelf(void) return ret; } +s32 LWP_GetThreadPriority(lwp_t thethread) +{ + u32 prio; + lwp_cntrl *lwp_thread; + + if(thethread==LWP_THREAD_NULL) thethread = LWP_GetSelf(); + + lwp_thread = __lwp_cntrl_open(thethread); + if(!lwp_thread) return -1; + + prio = __lwp_priotocore(lwp_thread->cur_prio); + + __lwp_thread_dispatchenable(); + return prio; +} + void LWP_SetThreadPriority(lwp_t thethread,u32 prio) { lwp_cntrl *lwp_thread;