Fixed bug 3504450.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4039 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2012-03-15 19:54:36 +00:00
parent 82984e1b55
commit 52e98077ee
3 changed files with 21 additions and 14 deletions

View File

@ -364,6 +364,7 @@ msg_t chMBFetchI(Mailbox *mbp, msg_t *msgp) {
if (chSemGetCounterI(&mbp->mb_fullsem) <= 0)
return RDY_TIMEOUT;
chSemFastWaitI(&mbp->mb_fullsem);
*msgp = *mbp->mb_rdptr++;
if (mbp->mb_rdptr >= mbp->mb_top)
mbp->mb_rdptr = mbp->mb_buffer;

View File

@ -79,6 +79,8 @@
*****************************************************************************
*** 2.5.0 ***
- FIX: Fixed chMBFetchI does not decrement mb_fullsem (bug 3504450)(backported
to 2.2.9 and 2.4.1).
- FIX: Fixed USART3 not working on STM32F2/F4 UART driver (bug 3496981)
(backported to 2.4.1).
- FIX: Fixed stack misalignment on Posix-MacOSX (bug 3495487)(backported

View File

@ -180,30 +180,34 @@ static void mbox1_execute(void) {
test_emit_token(msg2);
}
test_assert_sequence(29, "ABCDE");
test_assert(30, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
test_assert_lock(30, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(31, chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert(32, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
chSysLock();
msg1 = chMBPostAheadI(&mb1, 'E');
test_assert(31, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'D');
test_assert(32, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'C');
test_assert(33, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'B');
msg1 = chMBPostAheadI(&mb1, 'D');
test_assert(34, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'C');
test_assert(35, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'B');
test_assert(36, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'A');
chSysUnlock();
test_assert(35, msg1 == RDY_OK, "wrong wake-up message");
test_assert(36, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
test_assert(37, msg1 == RDY_OK, "wrong wake-up message");
test_assert(38, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
for (i = 0; i < MB_SIZE; i++) {
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
test_assert(37, msg1 == RDY_OK, "wrong wake-up message");
test_assert(39, msg1 == RDY_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(38, "ABCDE");
test_assert(39, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
test_assert_lock(39, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(40, chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert(41, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
/*
* Testing reset.
@ -213,10 +217,10 @@ static void mbox1_execute(void) {
/*
* Re-testing final conditions.
*/
test_assert_lock(40, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(41, chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert_lock(42, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
test_assert_lock(43, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
test_assert_lock(42, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(43, chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert_lock(44, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
test_assert_lock(45, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
}
ROMCONST struct testcase testmbox1 = {