diff --git a/os/common/abstractions/cmsis_os/cmsis_os.c b/os/common/abstractions/cmsis_os/cmsis_os.c index 154574281..c4f7c7dfe 100644 --- a/os/common/abstractions/cmsis_os/cmsis_os.c +++ b/os/common/abstractions/cmsis_os/cmsis_os.c @@ -208,8 +208,8 @@ osStatus osThreadSetPriority(osThreadId thread_id, osPriority newprio) { case CH_STATE_SNDMSGQ: #endif /* Re-enqueues tp with its new priority on the queue.*/ - ch_sch_prio_insert(ch_queue_dequeue(&tp->hdr.queue), - (ch_queue_t *)tp->u.wtobjp); + ch_sch_prio_insert((ch_queue_t *)tp->u.wtobjp, + ch_queue_dequeue(&tp->hdr.queue)); break; #endif case CH_STATE_READY: diff --git a/os/common/abstractions/nasa_cfe/osal/src/osapi.c b/os/common/abstractions/nasa_cfe/osal/src/osapi.c index 72ca29d37..af056fd98 100644 --- a/os/common/abstractions/nasa_cfe/osal/src/osapi.c +++ b/os/common/abstractions/nasa_cfe/osal/src/osapi.c @@ -2022,8 +2022,8 @@ int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { case CH_STATE_SNDMSGQ: #endif /* Re-enqueues tp with its new priority on the queue.*/ - ch_sch_prio_insert(ch_queue_dequeue(&tp->hdr.queue), - (ch_queue_t *)tp->u.wtobjp); + ch_sch_prio_insert((ch_queue_t *)tp->u.wtobjp, + ch_queue_dequeue(&tp->hdr.queue)); break; case CH_STATE_READY: #if CH_DBG_ENABLE_ASSERTS diff --git a/os/rt/include/chmsg.h b/os/rt/include/chmsg.h index 564c197ee..b5ebbb384 100644 --- a/os/rt/include/chmsg.h +++ b/os/rt/include/chmsg.h @@ -51,7 +51,7 @@ /*===========================================================================*/ #if CH_CFG_USE_MESSAGES_PRIORITY == TRUE -#define __ch_msg_insert(qp, tp) ch_sch_prio_insert(&tp->hdr.queue, qp) +#define __ch_msg_insert(qp, tp) ch_sch_prio_insert(qp, &tp->hdr.queue) #else #define __ch_msg_insert(qp, tp) ch_queue_insert(qp, &tp->hdr.queue) #endif diff --git a/os/rt/include/chschd.h b/os/rt/include/chschd.h index 7a1082f30..b9015bcd6 100644 --- a/os/rt/include/chschd.h +++ b/os/rt/include/chschd.h @@ -159,7 +159,7 @@ extern "C" { void chSchDoYieldS(void); thread_t *chSchSelectFirstI(void); #if CH_CFG_OPTIMIZE_SPEED == FALSE - void ch_sch_prio_insert(ch_queue_t *tp, ch_queue_t *qp); + void ch_sch_prio_insert(ch_queue_t *qp, ch_queue_t *tp); #endif /* CH_CFG_OPTIMIZE_SPEED == FALSE */ #ifdef __cplusplus } @@ -172,7 +172,7 @@ extern "C" { /* If the performance code path has been chosen then all the following functions are inlined into the various kernel modules.*/ #if CH_CFG_OPTIMIZE_SPEED == TRUE -static inline void ch_sch_prio_insert(ch_queue_t *tp, ch_queue_t *qp) { +static inline void ch_sch_prio_insert(ch_queue_t *qp, ch_queue_t *tp) { ch_queue_t *cp = qp; do { diff --git a/os/rt/src/chcond.c b/os/rt/src/chcond.c index 9378aa4fa..fadeafab8 100644 --- a/os/rt/src/chcond.c +++ b/os/rt/src/chcond.c @@ -217,7 +217,7 @@ msg_t chCondWaitS(condition_variable_t *cp) { /* Start waiting on the condition variable, on exit the mutex is taken again.*/ currtp->u.wtobjp = cp; - ch_sch_prio_insert(&currtp->hdr.queue, &cp->queue); + ch_sch_prio_insert(&cp->queue, &currtp->hdr.queue); chSchGoSleepS(CH_STATE_WTCOND); msg = currtp->u.rdymsg; chMtxLockS(mp); @@ -307,7 +307,7 @@ msg_t chCondWaitTimeoutS(condition_variable_t *cp, sysinterval_t timeout) { /* Start waiting on the condition variable, on exit the mutex is taken again.*/ currtp->u.wtobjp = cp; - ch_sch_prio_insert(&currtp->hdr.queue, &cp->queue); + ch_sch_prio_insert(&cp->queue, &currtp->hdr.queue); msg = chSchGoSleepTimeoutS(CH_STATE_WTCOND, timeout); if (msg != MSG_TIMEOUT) { chMtxLockS(mp); diff --git a/os/rt/src/chmtx.c b/os/rt/src/chmtx.c index 5b993187a..ba665fdf3 100644 --- a/os/rt/src/chmtx.c +++ b/os/rt/src/chmtx.c @@ -170,8 +170,8 @@ void chMtxLockS(mutex_t *mp) { switch (tp->state) { case CH_STATE_WTMTX: /* Re-enqueues the mutex owner with its new priority.*/ - ch_sch_prio_insert(ch_queue_dequeue(&tp->hdr.queue), - &tp->u.wtmtxp->queue); + ch_sch_prio_insert(&tp->u.wtmtxp->queue, + ch_queue_dequeue(&tp->hdr.queue)); tp = tp->u.wtmtxp->owner; /*lint -e{9042} [16.1] Continues the while.*/ continue; @@ -191,8 +191,8 @@ void chMtxLockS(mutex_t *mp) { case CH_STATE_SNDMSGQ: #endif /* Re-enqueues tp with its new priority on the queue.*/ - ch_sch_prio_insert(ch_queue_dequeue(&tp->hdr.queue), - &tp->u.wtmtxp->queue); + ch_sch_prio_insert(&tp->u.wtmtxp->queue, + ch_queue_dequeue(&tp->hdr.queue)); break; #endif case CH_STATE_READY: @@ -211,7 +211,7 @@ void chMtxLockS(mutex_t *mp) { } /* Sleep on the mutex.*/ - ch_sch_prio_insert(&currtp->hdr.queue, &mp->queue); + ch_sch_prio_insert(&mp->queue, &currtp->hdr.queue); currtp->u.wtmtxp = mp; chSchGoSleepS(CH_STATE_WTMTX); diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c index 3458e14a4..25a39a276 100644 --- a/os/rt/src/chschd.c +++ b/os/rt/src/chschd.c @@ -234,12 +234,12 @@ static void __sch_wakeup(void *p) { * @note The insertion is done by scanning the list from the highest * priority toward the lowest. * - * @param[in] tp the pointer to the thread to be inserted in the list * @param[in] qp the pointer to the threads list header + * @param[in] tp the pointer to the thread to be inserted in the list * * @notapi */ -void ch_sch_prio_insert(ch_queue_t *tp, ch_queue_t *qp) { +void ch_sch_prio_insert(ch_queue_t *qp, ch_queue_t *tp) { ch_queue_t *cp = qp; do { diff --git a/os/sb/host/sbhost.c b/os/sb/host/sbhost.c index 83d37b3c3..2c26f8b0d 100644 --- a/os/sb/host/sbhost.c +++ b/os/sb/host/sbhost.c @@ -171,7 +171,7 @@ msg_t sbSendMessageTimeout(sb_class_t *sbcp, /* Sending the message.*/ ctp->u.sentmsg = msg; - __ch_msg_insert(ctp, &sbcp->tp->msgqueue); + __ch_msg_insert(&sbcp->tp->msgqueue, ctp); if (sbcp->tp->state == CH_STATE_WTMSG) { (void) chSchReadyI(sbcp->tp); }