From 4ee79187645d1a2687f81de3f19320acbce733c8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jun 2010 11:17:33 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1982 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chsem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/kernel/src/chsem.c') diff --git a/os/kernel/src/chsem.c b/os/kernel/src/chsem.c index 2a86a14f6..2959b4d63 100644 --- a/os/kernel/src/chsem.c +++ b/os/kernel/src/chsem.c @@ -117,7 +117,7 @@ void chSemResetI(Semaphore *sp, cnt_t n) { cnt = sp->s_cnt; sp->s_cnt = n; - while (cnt++ < 0) + while (++cnt <= 0) chSchReadyI(lifo_remove(&sp->s_queue))->p_u.rdymsg = RDY_RESET; } @@ -220,7 +220,7 @@ void chSemSignal(Semaphore *sp) { chDbgCheck(sp != NULL, "chSemSignal"); chSysLock(); - if (sp->s_cnt++ < 0) + if (++sp->s_cnt <= 0) chSchWakeupS(fifo_remove(&sp->s_queue), RDY_OK); chSysUnlock(); } @@ -235,7 +235,7 @@ void chSemSignalI(Semaphore *sp) { chDbgCheck(sp != NULL, "chSemSignalI"); - if (sp->s_cnt++ < 0) { + if (++sp->s_cnt <= 0) { /* note, it is done this way in order to allow a tail call on chSchReadyI().*/ Thread *tp = fifo_remove(&sp->s_queue); @@ -261,7 +261,7 @@ msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw) { chDbgCheck((sps != NULL) && (spw != NULL), "chSemSignalWait"); chSysLock(); - if (sps->s_cnt++ < 0) + if (++sps->s_cnt <= 0) chSchReadyI(fifo_remove(&sps->s_queue))->p_u.rdymsg = RDY_OK; if (--spw->s_cnt < 0) { Thread *ctp = currp; -- cgit v1.2.3