Skip to content

Commit

Permalink
Fix priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed Apr 3, 2024
1 parent 503464f commit 12e3a10
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ee/libpthreadglue/src/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ pte_osResult pte_osTerminate(void) {
* Threads
*
***************************************************************************/

static inline int invert_priority(int priority)
{
return (pte_osThreadGetMinPriority() - priority) + pte_osThreadGetMaxPriority();
}

#ifdef F_pte_osThreadCreate
pte_osResult pte_osThreadCreate(pte_osThreadEntryPoint entryPoint,
int stackSize,
Expand Down Expand Up @@ -247,7 +253,7 @@ pte_osResult pte_osThreadCreate(pte_osThreadEntryPoint entryPoint,
eethread.stack = stack;
eethread.stack_size = stackSize;
eethread.gp_reg = &_gp;
eethread.initial_priority = initialPriority;
eethread.initial_priority = invert_priority(initialPriority);
threadId = CreateThread(&eethread);

/* In order to emulate TLS functionality, we append the address of the TLS structure that we
Expand Down Expand Up @@ -476,21 +482,21 @@ void pte_osThreadSleep(unsigned int msecs)
#ifdef F_pte_osThreadGetMinPriority
int pte_osThreadGetMinPriority()
{
return 17;
return pte_osThreadGetDefaultPriority() - 32;
}
#endif

#ifdef F_pte_osThreadGetMaxPriority
int pte_osThreadGetMaxPriority()
{
return 30;
return pte_osThreadGetDefaultPriority() + 32;
}
#endif

#ifdef F_pte_osThreadGetDefaultPriority
int pte_osThreadGetDefaultPriority()
{
return 18;
return 80;
}
#endif

Expand Down

0 comments on commit 12e3a10

Please sign in to comment.