aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chschd.c12
-rw-r--r--src/chsem.c28
-rw-r--r--src/chthreads.c1
-rw-r--r--src/include/delta.h14
-rw-r--r--src/include/threads.h5
-rw-r--r--src/templates/chtypes.h2
6 files changed, 27 insertions, 35 deletions
diff --git a/src/chschd.c b/src/chschd.c
index b38fe366f..a046f4fbf 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -188,17 +188,7 @@ void chSchTimerHandlerI(void) {
#endif
#ifdef CH_USE_VIRTUAL_TIMERS
- if (&dlist != (DeltaList *)dlist.dl_next) {
- VirtualTimer *vtp;
-
- --dlist.dl_next->vt_dtime;
- while (!(vtp = dlist.dl_next)->vt_dtime) {
- vtp->vt_prev->vt_next = vtp->vt_next;
- vtp->vt_next->vt_prev = vtp->vt_prev;
- vtp->vt_func(vtp->vt_par);
- vtp->vt_func = 0; // Required, flags the timer as triggered.
- }
- }
+ chVTDoTickI();
#endif
}
diff --git a/src/chsem.c b/src/chsem.c
index 1eab23ea4..058187050 100644
--- a/src/chsem.c
+++ b/src/chsem.c
@@ -288,7 +288,7 @@ void chSemLowerPrioSignal(Semaphore *sp) {
chSysLock();
if (!--currp->p_rtcnt) {
- currp->p_prio = currp->p_bakprio;
+ currp->p_prio -= MEPRIO;
if (sp->s_cnt++ < 0)
chSchReadyI(dequeue(sp->s_queue.p_next));
chSchRescheduleI();
@@ -308,14 +308,11 @@ void chSemLowerPrioSignal(Semaphore *sp) {
* option is enabled in \p chconf.h.
*/
void chSemRaisePrioSignalWait(Semaphore *sps, Semaphore *spw) {
- BOOL flag;
chSysLock();
if (sps->s_cnt++ < 0)
- chSchReadyI(dequeue(sps->s_queue.p_next)), flag = TRUE;
- else
- flag = FALSE;
+ chSchReadyI(dequeue(sps->s_queue.p_next));
if (--spw->s_cnt < 0) {
prioenq(currp, &spw->s_queue);
@@ -323,19 +320,13 @@ void chSemRaisePrioSignalWait(Semaphore *sps, Semaphore *spw) {
if (!currp->p_rtcnt++)
currp->p_prio += MEPRIO;
-
- chSysUnlock();
- return;
- }
-
- if (!currp->p_rtcnt++) {
- currp->p_bakprio = currp->p_prio;
- currp->p_prio += MEPRIO;
- flag = TRUE;
}
+ else {
+ if (!currp->p_rtcnt++)
+ currp->p_prio += MEPRIO;
- if( flag)
chSchRescheduleI();
+ }
chSysUnlock();
}
@@ -349,21 +340,20 @@ void chSemRaisePrioSignalWait(Semaphore *sps, Semaphore *spw) {
* option is enabled in \p chconf.h.
*/
void chSemLowerPrioSignalWait(Semaphore *sps, Semaphore *spw) {
- BOOL flag = FALSE;
chSysLock();
if (!--currp->p_rtcnt)
- currp->p_prio = currp->p_bakprio, flag = TRUE;
+ currp->p_prio -= MEPRIO;
if (sps->s_cnt++ < 0)
- chSchReadyI(dequeue(sps->s_queue.p_next)), flag = TRUE;
+ chSchReadyI(dequeue(sps->s_queue.p_next));
if (--spw->s_cnt < 0) {
enqueue(currp, &spw->s_queue); // enqueue() because the spw is a normal sem.
chSchGoSleepI(PRWTSEM);
}
- else if (flag)
+ else
chSchRescheduleI();
chSysUnlock();
diff --git a/src/chthreads.c b/src/chthreads.c
index 8f7112647..59c361116 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -61,7 +61,6 @@ void _InitThread(t_prio prio, t_tmode mode, Thread *tp) {
tp->p_rdymsg = RDY_OK;
#ifdef CH_USE_RT_SEMAPHORES
tp->p_rtcnt = 0;
- tp->p_bakprio = prio;
#endif
#ifdef CH_USE_WAITEXIT
tp->p_waiting.p_next = (Thread *)&tp->p_waiting;
diff --git a/src/include/delta.h b/src/include/delta.h
index 2ae4d887f..14f5b550e 100644
--- a/src/include/delta.h
+++ b/src/include/delta.h
@@ -69,6 +69,20 @@ typedef struct {
extern DeltaList dlist;
+#define chVTDoTickI() \
+ if (&dlist != (DeltaList *)dlist.dl_next) { \
+ VirtualTimer *vtp; \
+ \
+ --dlist.dl_next->vt_dtime; \
+ while (!(vtp = dlist.dl_next)->vt_dtime) { \
+ t_vtfunc fn = vtp->vt_func; \
+ vtp->vt_func = 0; \
+ vtp->vt_prev->vt_next = vtp->vt_next; \
+ vtp->vt_next->vt_prev = vtp->vt_prev; \
+ fn(vtp->vt_par); \
+ } \
+ }
+
/*
* Virtual Timers APIs.
*/
diff --git a/src/include/threads.h b/src/include/threads.h
index d8937433f..f170ce368 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -80,7 +80,7 @@ struct Thread {
#endif
};
/** Machine dependent processor context.*/
- Context p_ctx;
+ Context p_ctx;
/*
* Start of the optional fields. Note, the null thread may also let its
* stack overwrite the following fields since it never uses semaphores,
@@ -104,9 +104,8 @@ struct Thread {
#endif
#ifdef CH_USE_RT_SEMAPHORES
/** Priority backup after acquiring a RT semaphore.*/
- t_prio p_bakprio;
/** RT semaphores depth counter.*/
- WORD16 p_rtcnt;
+ int p_rtcnt;
#endif
};
diff --git a/src/templates/chtypes.h b/src/templates/chtypes.h
index 0d6547311..891b850c2 100644
--- a/src/templates/chtypes.h
+++ b/src/templates/chtypes.h
@@ -40,7 +40,7 @@
typedef BYTE8 t_tmode;
typedef BYTE8 t_tstate;
-typedef WORD16 t_prio;
+typedef LONG32 t_prio;
typedef PTR_EQ t_msg;
typedef LONG32 t_eventid;
typedef ULONG32 t_eventmask;