From b263680b98fbb41e939ce62e55916254ece4acc7 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 22 Jul 2017 09:53:49 +0000 Subject: Fixed bug #865. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10336 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/src/chsem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/rt/src') diff --git a/os/rt/src/chsem.c b/os/rt/src/chsem.c index 2b89884ab..90df0dd73 100644 --- a/os/rt/src/chsem.c +++ b/os/rt/src/chsem.c @@ -294,11 +294,11 @@ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) { void chSemSignal(semaphore_t *sp) { chDbgCheck(sp != NULL); + + chSysLock(); chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) || ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)), "inconsistent semaphore"); - - chSysLock(); if (++sp->cnt <= (cnt_t)0) { chSchWakeupS(queue_fifo_remove(&sp->queue), MSG_OK); } @@ -379,14 +379,14 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) { msg_t msg; chDbgCheck((sps != NULL) && (spw != NULL)); + + chSysLock(); chDbgAssert(((sps->cnt >= (cnt_t)0) && queue_isempty(&sps->queue)) || ((sps->cnt < (cnt_t)0) && queue_notempty(&sps->queue)), "inconsistent semaphore"); chDbgAssert(((spw->cnt >= (cnt_t)0) && queue_isempty(&spw->queue)) || ((spw->cnt < (cnt_t)0) && queue_notempty(&spw->queue)), "inconsistent semaphore"); - - chSysLock(); if (++sps->cnt <= (cnt_t)0) { chSchReadyI(queue_fifo_remove(&sps->queue))->u.rdymsg = MSG_OK; } -- cgit v1.2.3