diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2007-09-25 18:38:01 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2007-09-25 18:38:01 +0000 |
commit | 619b739d93252f4fc78a98e1bd1c36e9edbbca28 (patch) | |
tree | ab5a24e0e8be33bebab0ae9f9d85dd602328da2f /src | |
parent | f6c9ebb65b9a1239638125b7c1f910f12c722b79 (diff) | |
download | ChibiOS-619b739d93252f4fc78a98e1bd1c36e9edbbca28.tar.gz ChibiOS-619b739d93252f4fc78a98e1bd1c36e9edbbca28.tar.bz2 ChibiOS-619b739d93252f4fc78a98e1bd1c36e9edbbca28.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@21 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r-- | src/chschd.c | 12 | ||||
-rw-r--r-- | src/chsem.c | 28 | ||||
-rw-r--r-- | src/chthreads.c | 1 | ||||
-rw-r--r-- | src/include/delta.h | 14 | ||||
-rw-r--r-- | src/include/threads.h | 5 | ||||
-rw-r--r-- | src/templates/chtypes.h | 2 |
6 files changed, 35 insertions, 27 deletions
diff --git a/src/chschd.c b/src/chschd.c index a046f4fbf..b38fe366f 100644 --- a/src/chschd.c +++ b/src/chschd.c @@ -188,7 +188,17 @@ void chSchTimerHandlerI(void) { #endif
#ifdef CH_USE_VIRTUAL_TIMERS
- chVTDoTickI();
+ 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.
+ }
+ }
#endif
}
diff --git a/src/chsem.c b/src/chsem.c index 058187050..1eab23ea4 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 -= MEPRIO;
+ currp->p_prio = currp->p_bakprio;
if (sp->s_cnt++ < 0)
chSchReadyI(dequeue(sp->s_queue.p_next));
chSchRescheduleI();
@@ -308,11 +308,14 @@ 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));
+ chSchReadyI(dequeue(sps->s_queue.p_next)), flag = TRUE;
+ else
+ flag = FALSE;
if (--spw->s_cnt < 0) {
prioenq(currp, &spw->s_queue);
@@ -320,14 +323,20 @@ void chSemRaisePrioSignalWait(Semaphore *sps, Semaphore *spw) { if (!currp->p_rtcnt++)
currp->p_prio += MEPRIO;
+
+ chSysUnlock();
+ return;
}
- else {
- if (!currp->p_rtcnt++)
- currp->p_prio += MEPRIO;
- chSchRescheduleI();
+ if (!currp->p_rtcnt++) {
+ currp->p_bakprio = currp->p_prio;
+ currp->p_prio += MEPRIO;
+ flag = TRUE;
}
+ if( flag)
+ chSchRescheduleI();
+
chSysUnlock();
}
@@ -340,20 +349,21 @@ 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 -= MEPRIO;
+ currp->p_prio = currp->p_bakprio, flag = TRUE;
if (sps->s_cnt++ < 0)
- chSchReadyI(dequeue(sps->s_queue.p_next));
+ chSchReadyI(dequeue(sps->s_queue.p_next)), flag = TRUE;
if (--spw->s_cnt < 0) {
enqueue(currp, &spw->s_queue); // enqueue() because the spw is a normal sem.
chSchGoSleepI(PRWTSEM);
}
- else
+ else if (flag)
chSchRescheduleI();
chSysUnlock();
diff --git a/src/chthreads.c b/src/chthreads.c index 59c361116..8f7112647 100644 --- a/src/chthreads.c +++ b/src/chthreads.c @@ -61,6 +61,7 @@ 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 14f5b550e..2ae4d887f 100644 --- a/src/include/delta.h +++ b/src/include/delta.h @@ -69,20 +69,6 @@ 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 f170ce368..d8937433f 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,8 +104,9 @@ struct Thread { #endif
#ifdef CH_USE_RT_SEMAPHORES
/** Priority backup after acquiring a RT semaphore.*/
+ t_prio p_bakprio;
/** RT semaphores depth counter.*/
- int p_rtcnt;
+ WORD16 p_rtcnt;
#endif
};
diff --git a/src/templates/chtypes.h b/src/templates/chtypes.h index 891b850c2..0d6547311 100644 --- a/src/templates/chtypes.h +++ b/src/templates/chtypes.h @@ -40,7 +40,7 @@ typedef BYTE8 t_tmode;
typedef BYTE8 t_tstate;
-typedef LONG32 t_prio;
+typedef WORD16 t_prio;
typedef PTR_EQ t_msg;
typedef LONG32 t_eventid;
typedef ULONG32 t_eventmask;
|