Skip to content

Commit

Permalink
Add LWP_GetThreadPriority
Browse files Browse the repository at this point in the history
Co-authored-by: Exortile <[email protected]>
  • Loading branch information
Extrems and Exortile committed May 22, 2024
1 parent a773671 commit 8d2b894
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gc/ogc/lwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions libogc/lwp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8d2b894

Please sign in to comment.