aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/chevents.c4
-rw-r--r--src/chmsg.c8
-rw-r--r--src/chschd.c22
-rw-r--r--src/chsem.c16
-rw-r--r--src/chthreads.c2
-rw-r--r--src/include/scheduler.h2
6 files changed, 26 insertions, 28 deletions
diff --git a/src/chevents.c b/src/chevents.c
index e6d957700..13f20310d 100644
--- a/src/chevents.c
+++ b/src/chevents.c
@@ -114,7 +114,7 @@ void chEvtSendI(EventSource *esp) {
tp->p_epending |= EventMask(elp->el_id);
if ((tp->p_state == PRWTEVENT) && (tp->p_epending & tp->p_ewmask))
- chSchReadyI(tp);
+ chSchReadyI(tp, RDY_OK);
elp = elp->el_next;
}
}
@@ -165,7 +165,7 @@ static void wakeup(void *p) {
if (((Thread *)p)->p_state != PRWTEVENT)
chDbgPanic("chevents.c, wakeup()\r\n");
#endif
- chSchReadyI(p)->p_rdymsg = RDY_TIMEOUT;
+ chSchReadyI(p, RDY_TIMEOUT);
}
/**
diff --git a/src/chmsg.c b/src/chmsg.c
index b70ebbcfe..51675e0fe 100644
--- a/src/chmsg.c
+++ b/src/chmsg.c
@@ -39,7 +39,7 @@ t_msg chMsgSend(Thread *tp, t_msg msg) {
fifo_insert(currp, &tp->p_msgqueue);
currp->p_msg = msg;
if (tp->p_state == PRWTMSG)
- chSchReadyI(tp);
+ chSchReadyI(tp, RDY_OK);
chSchGoSleepS(PRSNDMSG);
msg = currp->p_rdymsg;
@@ -68,7 +68,7 @@ t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp) {
fifo_insert(currp, &tp->p_msgqueue);
// if (tp->p_state == PRWTMSG)
-// chSchReadyI(tp);
+// chSchReadyI(tp, RDY_OK);
chEvtSendI(esp);
currp->p_msg = msg;
chSchGoSleepS(PRSNDMSG);
@@ -86,7 +86,7 @@ static void wakeup(void *p) {
if (((Thread *)p)->p_state != PRSNDMSG)
chDbgPanic("chmsg.c, wakeup()\r\n");
#endif
- chSchReadyI(dequeue(p))->p_rdymsg = RDY_TIMEOUT;
+ chSchReadyI(dequeue(p), RDY_TIMEOUT);
}
/**
@@ -113,7 +113,7 @@ t_msg chMsgSendTimeout(Thread *tp, t_msg msg, t_time time) {
chVTSetI(&vt, time, wakeup, currp);
fifo_insert(currp, &tp->p_msgqueue);
if (tp->p_state == PRWTMSG)
- chSchReadyI(tp);
+ chSchReadyI(tp, RDY_OK);
currp->p_msg = msg;
chSchGoSleepS(PRSNDMSG);
msg = currp->p_rdymsg;
diff --git a/src/chschd.c b/src/chschd.c
index a6299644e..45b6c266c 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -55,6 +55,7 @@ void chSchInit(void) {
/**
* Inserts a thread in the Ready List.
* @param tp the Thread to be made ready
+ * @param msg message to the awakened thread
* @return the Thread pointer
* @note The function must be called in the system mutex zone.
* @note The function does not reschedule, the \p chSchRescheduleI() should
@@ -63,27 +64,24 @@ void chSchInit(void) {
*/
#ifdef CH_OPTIMIZE_SPEED
/* NOTE: it is inlined in this module only.*/
-INLINE Thread *chSchReadyI(Thread *tp) {
+INLINE void chSchReadyI(Thread *tp, t_msg msg) {
#else
-Thread *chSchReadyI(Thread *tp) {
+void chSchReadyI(Thread *tp, t_msg msg) {
#endif
Thread *cp = rlist.r_queue.p_prev;
- t_prio prio = tp->p_prio;
tp->p_state = PRREADY;
- tp->p_rdymsg = RDY_OK;
- while (cp->p_prio < prio)
+ tp->p_rdymsg = msg;
+ while (cp->p_prio < tp->p_prio)
cp = cp->p_prev;
- // Insertion on p_next
+ /* Insertion on p_next.*/
tp->p_next = (tp->p_prev = cp)->p_next;
tp->p_next->p_prev = cp->p_next = tp;
- return tp;
}
/*
* Switches to the next thread in the ready list, the ready list is assumed
* to contain at least a thread.
- * NOTE: it is inlined in this module only.
*/
#ifdef CH_OPTIMIZE_SPEED
static INLINE void nextready(void) {
@@ -120,7 +118,7 @@ void chSchGoSleepS(t_tstate newstate) {
* running directly depending on its relative priority compared to the current
* thread.
* @param ntp the Thread to be made ready
- * @param msg wakeup message to the awakened thread
+ * @param msg message to the awakened thread
* @note The function must be called in the system mutex zone.
* @note The function is not meant to be used in the user code directly.
* @note It is equivalent to a \p chSchReadyI() followed by a
@@ -129,10 +127,10 @@ void chSchGoSleepS(t_tstate newstate) {
void chSchWakeupS(Thread *ntp, t_msg msg) {
if (ntp->p_prio <= currp->p_prio)
- chSchReadyI(ntp)->p_rdymsg = msg;
+ chSchReadyI(ntp, msg);
else {
Thread *otp = currp;
- chSchReadyI(otp);
+ chSchReadyI(otp, RDY_OK);
(currp = ntp)->p_state = PRCURR;
ntp->p_rdymsg = msg;
rlist.r_preempt = CH_TIME_QUANTUM;
@@ -162,7 +160,7 @@ void chSchRescheduleS(void) {
*/
void chSchDoRescheduleI(void) {
- chSchReadyI(currp);
+ chSchReadyI(currp, RDY_OK);
nextready();
}
diff --git a/src/chsem.c b/src/chsem.c
index 099dc4db4..6f24b08ec 100644
--- a/src/chsem.c
+++ b/src/chsem.c
@@ -54,7 +54,7 @@ void chSemReset(Semaphore *sp, t_cnt n) {
sp->s_cnt = n;
if (cnt < 0) {
while (cnt++)
- chSchReadyI(fifo_remove(&sp->s_queue))->p_rdymsg = RDY_RESET;
+ chSchReadyI(fifo_remove(&sp->s_queue), RDY_RESET);
chSchRescheduleS();
}
@@ -76,7 +76,7 @@ void chSemResetI(Semaphore *sp, t_cnt n) {
cnt = sp->s_cnt;
sp->s_cnt = n;
while (cnt++ < 0)
- chSchReadyI(fifo_remove(&sp->s_queue))->p_rdymsg = RDY_RESET;
+ chSchReadyI(fifo_remove(&sp->s_queue), RDY_RESET);
}
/**
@@ -118,7 +118,7 @@ static void wakeup(void *p) {
chDbgPanic("chsem.c, wakeup()\r\n");
#endif
chSemFastSignalI(((Thread *)p)->p_semp);
- chSchReadyI(dequeue(p))->p_rdymsg = RDY_TIMEOUT;
+ chSchReadyI(dequeue(p), RDY_TIMEOUT);
}
/**
@@ -205,7 +205,7 @@ void chSemSignal(Semaphore *sp) {
void chSemSignalI(Semaphore *sp) {
if (sp->s_cnt++ < 0)
- chSchReadyI(fifo_remove(&sp->s_queue));
+ chSchReadyI(fifo_remove(&sp->s_queue), RDY_OK);
}
#ifdef CH_USE_SEMSW
@@ -221,7 +221,7 @@ void chSemSignalWait(Semaphore *sps, Semaphore *spw) {
chSysLock();
if (sps->s_cnt++ < 0)
- chSchReadyI(fifo_remove(&sps->s_queue));
+ chSchReadyI(fifo_remove(&sps->s_queue), RDY_OK);
if (--spw->s_cnt < 0) {
fifo_insert(currp, &spw->s_queue);
@@ -289,7 +289,7 @@ void chSemLowerPrioSignal(Semaphore *sp) {
if (!--currp->p_rtcnt) {
currp->p_prio -= MEPRIO;
if (sp->s_cnt++ < 0)
- chSchReadyI(fifo_remove(&sp->s_queue));
+ chSchReadyI(fifo_remove(&sp->s_queue), RDY_OK);
chSchRescheduleS();
}
else if (sp->s_cnt++ < 0)
@@ -312,7 +312,7 @@ void chSemRaisePrioSignalWait(Semaphore *sps, Semaphore *spw) {
chSysLock();
if (sps->s_cnt++ < 0)
- chSchReadyI(fifo_remove(&sps->s_queue));
+ chSchReadyI(fifo_remove(&sps->s_queue), RDY_OK);
if (--spw->s_cnt < 0) {
prioenq(currp, &spw->s_queue);
@@ -348,7 +348,7 @@ void chSemLowerPrioSignalWait(Semaphore *sps, Semaphore *spw) {
currp->p_prio -= MEPRIO;
if (sps->s_cnt++ < 0)
- chSchReadyI(fifo_remove(&sps->s_queue));
+ chSchReadyI(fifo_remove(&sps->s_queue), RDY_OK);
if (--spw->s_cnt < 0) {
fifo_insert(currp, &spw->s_queue); // fifo_insert() because the spw is a normal sem.
diff --git a/src/chthreads.c b/src/chthreads.c
index 9729a9b59..f58e58ebe 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -198,7 +198,7 @@ void chThdExit(t_msg msg) {
currp->p_exitcode = msg; /* Post mortem info. */
#ifdef CH_USE_WAITEXIT
while (notempty(&currp->p_waiting))
- chSchReadyI(list_remove(&currp->p_waiting));
+ chSchReadyI(list_remove(&currp->p_waiting), RDY_OK);
#endif
#ifdef CH_USE_EXIT_EVENT
chEvtSendI(&currp->p_exitesource);
diff --git a/src/include/scheduler.h b/src/include/scheduler.h
index 40130f356..c56773ee1 100644
--- a/src/include/scheduler.h
+++ b/src/include/scheduler.h
@@ -50,7 +50,7 @@ typedef struct {
extern "C" {
#endif
void chSchInit(void);
- Thread *chSchReadyI(Thread *tp);
+ void chSchReadyI(Thread *tp, t_msg msg);
void chSchGoSleepS(t_tstate newstate);
void chSchWakeupS(Thread *tp, t_msg msg);
void chSchRescheduleS(void);