git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@781 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
6b6e5b95fb
commit
4c2be4a8e9
|
@ -80,6 +80,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
|
||||||
- FIX: Fixed wrong assertions in chThdWait() and chHeapFree() (backported in
|
- FIX: Fixed wrong assertions in chThdWait() and chHeapFree() (backported in
|
||||||
stable branch).
|
stable branch).
|
||||||
- FIX: Fixed a small problem in the chcore.c template file.
|
- FIX: Fixed a small problem in the chcore.c template file.
|
||||||
|
- NEW: Mailboxes (asynchronous messages) subsystem and test cases added.
|
||||||
- NEW: Mode flexible debug configuration options, removed the old CH_USE_DEBUG
|
- NEW: Mode flexible debug configuration options, removed the old CH_USE_DEBUG
|
||||||
and CH_USE_TRACE. Replaced with CH_DBG_ENABLE_ASSERTS, CH_DBG_ENABLE_TRACE
|
and CH_USE_TRACE. Replaced with CH_DBG_ENABLE_ASSERTS, CH_DBG_ENABLE_TRACE
|
||||||
and CH_DBG_FILL_THREADS.
|
and CH_DBG_FILL_THREADS.
|
||||||
|
|
|
@ -40,6 +40,7 @@ void trace_init(void) {
|
||||||
trace_buffer.tb_size = TRACE_BUFFER_SIZE;
|
trace_buffer.tb_size = TRACE_BUFFER_SIZE;
|
||||||
trace_buffer.tb_ptr = &trace_buffer.tb_buffer[0];
|
trace_buffer.tb_ptr = &trace_buffer.tb_buffer[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inserts in the circular debug trace buffer a context switch record.
|
* @brief Inserts in the circular debug trace buffer a context switch record.
|
||||||
*
|
*
|
||||||
|
|
|
@ -86,6 +86,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#if CH_DBG_ENABLE_TRACE
|
#if CH_DBG_ENABLE_TRACE
|
||||||
extern TraceBuffer trace_buffer;
|
extern TraceBuffer trace_buffer;
|
||||||
|
void trace_init(void);
|
||||||
void chDbgTrace(Thread *otp, Thread *ntp);
|
void chDbgTrace(Thread *otp, Thread *ntp);
|
||||||
#endif
|
#endif
|
||||||
#if CH_DBG_ENABLE_ASSERTS
|
#if CH_DBG_ENABLE_ASSERTS
|
||||||
|
|
|
@ -52,22 +52,33 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies if the mailbox has space for an immediate message.
|
* Returns the mailbox buffer size.
|
||||||
|
* @param[in] mbp the pointer to an initialized Mailbox object
|
||||||
|
*/
|
||||||
|
#define chMBSize(mbp) \
|
||||||
|
((mbp)->mb_top - (mbp)->mb_buffer)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the free space into the mailbox.
|
||||||
* @param[in] mbp the pointer to an initialized Mailbox object
|
* @param[in] mbp the pointer to an initialized Mailbox object
|
||||||
* @return The number of empty message slots.
|
* @return The number of empty message slots.
|
||||||
* @note Can be invoked in any system state but if invoked out of a locked
|
* @note Can be invoked in any system state but if invoked out of a locked
|
||||||
* state then the returned value may change after reading.
|
* state then the returned value may change after reading.
|
||||||
|
* @note The returned value can be less than zero when there are waiting
|
||||||
|
* threads on the internal semaphore.
|
||||||
*/
|
*/
|
||||||
#define chMBHasSpace(mbp) chSemGetCounterI(&(mbp)->mb_emptysem)
|
#define chMBGetEmpty(mbp) chSemGetCounterI(&(mbp)->mb_emptysem)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies if the mailbox has incoming messages.
|
* Returns the number of messages into the mailbox.
|
||||||
* @param[in] mbp the pointer to an initialized Mailbox object
|
* @param[in] mbp the pointer to an initialized Mailbox object
|
||||||
* @return The number of queued messages.
|
* @return The number of queued messages.
|
||||||
* @note Can be invoked in any system state but if invoked out of a locked
|
* @note Can be invoked in any system state but if invoked out of a locked
|
||||||
* state then the returned value may change after reading.
|
* state then the returned value may change after reading.
|
||||||
|
* @note The returned value can be less than zero when there are waiting
|
||||||
|
* threads on the internal semaphore.
|
||||||
*/
|
*/
|
||||||
#define chMBContainsMessages(mbp) chSemGetCounterI(&(mbp)->mb_fullsem)
|
#define chMBGetFull(mbp) chSemGetCounterI(&(mbp)->mb_fullsem)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next message in the queue without removing it.
|
* Returns the next message in the queue without removing it.
|
||||||
|
|
|
@ -58,29 +58,27 @@ typedef struct {
|
||||||
} Queue;
|
} Queue;
|
||||||
|
|
||||||
/** Returns the queue's buffer size. */
|
/** Returns the queue's buffer size. */
|
||||||
#define chQSize(q) \
|
#define chQSize(q) ((q)->q_top - (q)->q_buffer)
|
||||||
((q)->q_top - (q)->q_buffer)
|
|
||||||
|
|
||||||
/** Returns the used space if used on an Input Queue and the empty space if
|
/**
|
||||||
* used on an Output Queue. */
|
* Returns the used space if used on an Input Queue and the empty space if
|
||||||
#define chQSpace(q) \
|
* used on an Output Queue.
|
||||||
((q)->q_sem.s_cnt)
|
* @note The returned value can be less than zero when there are waiting
|
||||||
|
* threads on the internal semaphore.
|
||||||
|
*/
|
||||||
|
#define chQSpace(q) chSemGetCounterI(&(q)->q_sem)
|
||||||
|
|
||||||
/** Evaluates to TRUE if the specified Input Queue is empty. */
|
/** Evaluates to TRUE if the specified Input Queue is empty. */
|
||||||
#define chIQIsEmpty(q) \
|
#define chIQIsEmpty(q) (chQSpace(q) <= 0)
|
||||||
(chQSpace(q) <= 0)
|
|
||||||
|
|
||||||
/** Evaluates to TRUE if the specified Input Queue is full. */
|
/** Evaluates to TRUE if the specified Input Queue is full. */
|
||||||
#define chIQIsFull(q) \
|
#define chIQIsFull(q) (chQSpace(q) >= chQSize(q))
|
||||||
(chQSpace(q) >= chQSize(q))
|
|
||||||
|
|
||||||
/** Evaluates to TRUE if the specified Output Queue is empty. */
|
/** Evaluates to TRUE if the specified Output Queue is empty. */
|
||||||
#define chOQIsEmpty(q) \
|
#define chOQIsEmpty(q) (chQSpace(q) >= chQSize(q))
|
||||||
(chQSpace(q) >= chQSize(q))
|
|
||||||
|
|
||||||
/** Evaluates to TRUE if the specified Output Queue is full. */
|
/** Evaluates to TRUE if the specified Output Queue is full. */
|
||||||
#define chOQIsFull(q) \
|
#define chOQIsFull(q) (chQSpace(q) <= 0)
|
||||||
(chQSpace(q) <= 0)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -131,28 +129,30 @@ typedef struct {
|
||||||
} HalfDuplexQueue;
|
} HalfDuplexQueue;
|
||||||
|
|
||||||
/** Returns the queue's buffer size. */
|
/** Returns the queue's buffer size. */
|
||||||
#define chHDQSize(q) \
|
#define chHDQSize(q) ((q)->hdq_top - (q)->hdq_buffer)
|
||||||
((q)->hdq_top - (q)->hdq_buffer)
|
|
||||||
|
|
||||||
/** Returns the queue space when in transmission mode. */
|
/**
|
||||||
#define chHDQEmptySpace(q) \
|
* Returns the queue space when in transmission mode.
|
||||||
((q)->hdq_osem.s_cnt)
|
* @note The returned value can be less than zero when there are waiting
|
||||||
|
* threads on the internal semaphore.
|
||||||
|
*/
|
||||||
|
#define chHDQEmptySpace(q) chSemGetCounterI(&(q)->hdq_osem)
|
||||||
|
|
||||||
/** Returns the number of the bytes in the queue when in receive mode. */
|
/**
|
||||||
#define chHDQFilledSpace(q) \
|
* Returns the number of the bytes in the queue when in receive mode.
|
||||||
((q)->hdq_isem.s_cnt)
|
* @note The returned value can be less than zero when there are waiting
|
||||||
|
* threads on the internal semaphore.
|
||||||
|
*/
|
||||||
|
#define chHDQFilledSpace(q) chSemGetCounterI(&(q)->hdq_isem)
|
||||||
|
|
||||||
/** Evaluates to TRUE if the queue is in transmit mode. */
|
/** Evaluates to TRUE if the queue is in transmit mode. */
|
||||||
#define chHDQIsTransmitting(q) \
|
#define chHDQIsTransmitting(q) (chHDQEmptySpace(q) < chHDQSize(q))
|
||||||
(chHDQEmptySpace(q) < chHDQSize(q))
|
|
||||||
|
|
||||||
/** Evaluates to TRUE if the queue is in receive mode. */
|
/** Evaluates to TRUE if the queue is in receive mode. */
|
||||||
#define chHDQIsReceiving(q) \
|
#define chHDQIsReceiving(q) (chHDQEmptySpaceQ(q) >= chHDQSize(q))
|
||||||
(chHDQEmptySpaceQ(q) >= chHDQSize(q))
|
|
||||||
|
|
||||||
/** Evaluates to TRUE if the receive queue is full. */
|
/** Evaluates to TRUE if the receive queue is full. */
|
||||||
#define chHDQIsFullReceive(q) \
|
#define chHDQIsFullReceive(q) (chHDQFilledSpace(q) >= chHDQSize(q))
|
||||||
(chHDQFilledSpace(q) >= chHDQSize(q))
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "testmtx.h"
|
#include "testmtx.h"
|
||||||
#include "testcond.h"
|
#include "testcond.h"
|
||||||
#include "testmsg.h"
|
#include "testmsg.h"
|
||||||
|
#include "testmbox.h"
|
||||||
#include "testevt.h"
|
#include "testevt.h"
|
||||||
#include "testheap.h"
|
#include "testheap.h"
|
||||||
#include "testpools.h"
|
#include "testpools.h"
|
||||||
|
@ -40,6 +41,7 @@ static const struct testcase **patterns[] = {
|
||||||
patternmtx,
|
patternmtx,
|
||||||
patterncond,
|
patterncond,
|
||||||
patternmsg,
|
patternmsg,
|
||||||
|
patternmbox,
|
||||||
patternevt,
|
patternevt,
|
||||||
patternheap,
|
patternheap,
|
||||||
patternpools,
|
patternpools,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# List of all the ChibiOS/RT test files.
|
# List of all the ChibiOS/RT test files.
|
||||||
TESTSRC = ../../test/test.c ../../test/testrdy.c ../../test/testsem.c \
|
TESTSRC = ../../test/test.c ../../test/testrdy.c ../../test/testsem.c \
|
||||||
../../test/testmtx.c ../../test/testcond.c ../../test/testmsg.c \
|
../../test/testmtx.c ../../test/testcond.c ../../test/testmsg.c \
|
||||||
../../test/testevt.c ../../test/testheap.c ../../test/testpools.c \
|
../../test/testmbox.c ../../test/testevt.c ../../test/testheap.c \
|
||||||
../../test/testdyn.c ../../test/testbmk.c
|
../../test/testpools.c ../../test/testdyn.c ../../test/testbmk.c
|
||||||
|
|
||||||
# Required include directories
|
# Required include directories
|
||||||
TESTINC = ../../test
|
TESTINC = ../../test
|
||||||
|
|
|
@ -55,7 +55,7 @@ static void cond1_execute(void) {
|
||||||
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C");
|
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C");
|
||||||
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B");
|
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B");
|
||||||
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
|
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
|
||||||
test_assert(prio == chThdGetPriority(), "priority return failure");
|
test_assert(prio == chThdGetPriority(), "#1"); /* Priority return failure.*/
|
||||||
chCondSignal(&c1);
|
chCondSignal(&c1);
|
||||||
chCondSignal(&c1);
|
chCondSignal(&c1);
|
||||||
chCondSignal(&c1);
|
chCondSignal(&c1);
|
||||||
|
@ -86,7 +86,7 @@ static void cond2_execute(void) {
|
||||||
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C");
|
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C");
|
||||||
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B");
|
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B");
|
||||||
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
|
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
|
||||||
test_assert(prio == chThdGetPriority(), "priority return failure");
|
test_assert(prio == chThdGetPriority(), "#1"); /* Priority return failure.*/
|
||||||
chCondBroadcast(&c1);
|
chCondBroadcast(&c1);
|
||||||
test_wait_threads();
|
test_wait_threads();
|
||||||
test_assert_sequence("ABCDE");
|
test_assert_sequence("ABCDE");
|
||||||
|
|
|
@ -52,15 +52,15 @@ static void dyn1_execute(void) {
|
||||||
(threads[2] == NULL) &&
|
(threads[2] == NULL) &&
|
||||||
(threads[3] == NULL) &&
|
(threads[3] == NULL) &&
|
||||||
(threads[4] == NULL),
|
(threads[4] == NULL),
|
||||||
"thread creation failed");
|
"#1"); /* Thread creation failed.*/
|
||||||
|
|
||||||
/* Claiming the memory from terminated threads. */
|
/* Claiming the memory from terminated threads. */
|
||||||
test_wait_threads();
|
test_wait_threads();
|
||||||
test_assert_sequence("AB");
|
test_assert_sequence("AB");
|
||||||
|
|
||||||
/* Heap status checked again.*/
|
/* Heap status checked again.*/
|
||||||
test_assert(chHeapStatus(&n) == 1, "heap fragmented");
|
test_assert(chHeapStatus(&n) == 1, "#2"); /* Heap fragmented.*/
|
||||||
test_assert(n == sz, "heap size changed");
|
test_assert(n == sz, "#3"); /* Heap size changed.*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ static void dyn2_execute(void) {
|
||||||
(threads[2] != NULL) &&
|
(threads[2] != NULL) &&
|
||||||
(threads[3] != NULL) &&
|
(threads[3] != NULL) &&
|
||||||
(threads[4] != NULL),
|
(threads[4] != NULL),
|
||||||
"thread creation failed");
|
"#1"); /* Thread creation failed.*/
|
||||||
|
|
||||||
/* Claiming the memory from terminated threads. */
|
/* Claiming the memory from terminated threads. */
|
||||||
test_wait_threads();
|
test_wait_threads();
|
||||||
|
@ -113,8 +113,8 @@ static void dyn2_execute(void) {
|
||||||
|
|
||||||
/* Now the pool must be full again. */
|
/* Now the pool must be full again. */
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
test_assert(chPoolAlloc(&mp1) != NULL, "pool list empty");
|
test_assert(chPoolAlloc(&mp1) != NULL, "#2"); /* Pool list empty.*/
|
||||||
test_assert(chPoolAlloc(&mp1) == NULL, "pool list not empty");
|
test_assert(chPoolAlloc(&mp1) == NULL, "#3"); /* Pool list not empty.*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct testcase testdyn2 = {
|
const struct testcase testdyn2 = {
|
||||||
|
|
|
@ -55,20 +55,20 @@ static void evt1_execute(void) {
|
||||||
*/
|
*/
|
||||||
chEvtPend(5);
|
chEvtPend(5);
|
||||||
m = chEvtWaitOne(ALL_EVENTS);
|
m = chEvtWaitOne(ALL_EVENTS);
|
||||||
test_assert(m == 1, "chEvtWaitOne() error");
|
test_assert(m == 1, "#1"); /* Single bit error.*/
|
||||||
m = chEvtWaitOne(ALL_EVENTS);
|
m = chEvtWaitOne(ALL_EVENTS);
|
||||||
test_assert(m == 4, "chEvtWaitOne() error");
|
test_assert(m == 4, "#2"); /* Single bit error.*/
|
||||||
m = chEvtClear(0);
|
m = chEvtClear(0);
|
||||||
test_assert(m == 0, "stuck event");
|
test_assert(m == 0, "#3"); /* Stuck event.*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test on chEvtWaitAny().
|
* Test on chEvtWaitAny().
|
||||||
*/
|
*/
|
||||||
chEvtPend(5);
|
chEvtPend(5);
|
||||||
m = chEvtWaitAny(ALL_EVENTS);
|
m = chEvtWaitAny(ALL_EVENTS);
|
||||||
test_assert(m == 5, "chEvtWaitAny() error");
|
test_assert(m == 5, "#4"); /* Unexpected pending.*/
|
||||||
m = chEvtClear(0);
|
m = chEvtClear(0);
|
||||||
test_assert(m == 0, "stuck event");
|
test_assert(m == 0, "#5"); /* Stuck event.*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test on chEvtWaitAll(), chEvtRegisterMask() and chEvtUnregister().
|
* Test on chEvtWaitAll(), chEvtRegisterMask() and chEvtUnregister().
|
||||||
|
@ -82,13 +82,13 @@ static void evt1_execute(void) {
|
||||||
m = chEvtWaitAll(5);
|
m = chEvtWaitAll(5);
|
||||||
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
|
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
|
||||||
m = chEvtClear(0);
|
m = chEvtClear(0);
|
||||||
test_assert(m == 0, "stuck event");
|
test_assert(m == 0, "#6"); /* Stuck event.*/
|
||||||
|
|
||||||
test_wait_threads();
|
test_wait_threads();
|
||||||
chEvtUnregister(&es1, &el1);
|
chEvtUnregister(&es1, &el1);
|
||||||
chEvtUnregister(&es2, &el2);
|
chEvtUnregister(&es2, &el2);
|
||||||
test_assert(!chEvtIsListening(&es1), "stuck listener");
|
test_assert(!chEvtIsListening(&es1), "#7"); /* Stuck listener.*/
|
||||||
test_assert(!chEvtIsListening(&es2), "stuck listener");
|
test_assert(!chEvtIsListening(&es2), "#8"); /* Stuck listener.*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct testcase testevt1 = {
|
const struct testcase testevt1 = {
|
||||||
|
|
|
@ -47,7 +47,7 @@ static void heap1_execute(void) {
|
||||||
chHeapFree(p1); /* Does not merge */
|
chHeapFree(p1); /* Does not merge */
|
||||||
chHeapFree(p2); /* Merges backward */
|
chHeapFree(p2); /* Merges backward */
|
||||||
chHeapFree(p3); /* Merges both sides */
|
chHeapFree(p3); /* Merges both sides */
|
||||||
test_assert(chHeapStatus(&n) == 1, "heap fragmented #1");
|
test_assert(chHeapStatus(&n) == 1, "#1"); /* Heap fragmented.*/
|
||||||
|
|
||||||
/* Reverse order */
|
/* Reverse order */
|
||||||
p1 = chHeapAlloc(SIZE);
|
p1 = chHeapAlloc(SIZE);
|
||||||
|
@ -56,9 +56,9 @@ static void heap1_execute(void) {
|
||||||
chHeapFree(p3); /* Merges forward */
|
chHeapFree(p3); /* Merges forward */
|
||||||
chHeapFree(p2); /* Merges forward */
|
chHeapFree(p2); /* Merges forward */
|
||||||
chHeapFree(p1); /* Merges forward */
|
chHeapFree(p1); /* Merges forward */
|
||||||
test_assert(chHeapStatus(&n) == 1, "heap fragmented #2");
|
test_assert(chHeapStatus(&n) == 1, "#2"); /* Heap fragmented.*/
|
||||||
|
|
||||||
test_assert(n == sz, "heap size changed");
|
test_assert(n == sz, "#3"); /* Heap size changed.*/
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
test_print("--- Size : ");
|
test_print("--- Size : ");
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ch.h>
|
||||||
|
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
#if CH_USE_MAILBOXES && CH_USE_SEMAPHORES_TIMEOUT
|
||||||
|
|
||||||
|
#define ALLOWED_DELAY MS2ST(5)
|
||||||
|
#define MB_SIZE 5
|
||||||
|
|
||||||
|
static msg_t mb1_buf[MB_SIZE];
|
||||||
|
static Mailbox mb1;
|
||||||
|
|
||||||
|
static char *mbox1_gettest(void) {
|
||||||
|
|
||||||
|
return "Mailboxes, queuing and timeouts";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mbox1_setup(void) {
|
||||||
|
|
||||||
|
chMBInit(&mb1, mb1_buf, MB_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mbox1_execute(void) {
|
||||||
|
msg_t msg1, msg2;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
/* Testing initial space.*/
|
||||||
|
test_assert(chMBGetEmpty(&mb1) == MB_SIZE, "#1");
|
||||||
|
|
||||||
|
/* Testing enqueuing.*/
|
||||||
|
for (i = 0; i < MB_SIZE - 1; i++) {
|
||||||
|
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
|
||||||
|
test_assert(msg1 == RDY_OK, "#2");
|
||||||
|
}
|
||||||
|
msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE);
|
||||||
|
test_assert(msg1 == RDY_OK, "#3");
|
||||||
|
|
||||||
|
/* Testing post timeout.*/
|
||||||
|
msg1 = chMBPost(&mb1, 'X', 1);
|
||||||
|
test_assert(msg1 == RDY_TIMEOUT, "#4");
|
||||||
|
|
||||||
|
/* Testing final conditions.*/
|
||||||
|
test_assert(chMBGetEmpty(&mb1) == 0, "#5");
|
||||||
|
test_assert(chMBGetFull(&mb1) == MB_SIZE, "#6");
|
||||||
|
test_assert(mb1.mb_rdptr == mb1.mb_wrptr, "#7");
|
||||||
|
|
||||||
|
/* Testing dequeuing.*/
|
||||||
|
for (i = 0; i < MB_SIZE; i++) {
|
||||||
|
msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE);
|
||||||
|
test_assert(msg1 == RDY_OK, "#8");
|
||||||
|
test_emit_token(msg2);
|
||||||
|
}
|
||||||
|
test_assert_sequence("ABCDE");
|
||||||
|
|
||||||
|
/* Testing fetch timeout.*/
|
||||||
|
msg1 = chMBFetch(&mb1, &msg2, 1);
|
||||||
|
test_assert(msg1 == RDY_TIMEOUT, "#9");
|
||||||
|
|
||||||
|
/* Testing final conditions.*/
|
||||||
|
test_assert(chMBGetEmpty(&mb1) == MB_SIZE, "#10");
|
||||||
|
test_assert(chMBGetFull(&mb1) == 0, "#11");
|
||||||
|
test_assert(mb1.mb_rdptr == mb1.mb_wrptr, "#12");
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct testcase testmbox1 = {
|
||||||
|
mbox1_gettest,
|
||||||
|
mbox1_setup,
|
||||||
|
NULL,
|
||||||
|
mbox1_execute
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CH_USE_MAILBOXES && CH_USE_SEMAPHORES_TIMEOUT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test sequence for mailboxes pattern.
|
||||||
|
*/
|
||||||
|
const struct testcase *patternmbox[] = {
|
||||||
|
#if CH_USE_MAILBOXES && CH_USE_SEMAPHORES_TIMEOUT
|
||||||
|
&testmbox1,
|
||||||
|
#endif
|
||||||
|
NULL
|
||||||
|
};
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TESTMBOX_H_
|
||||||
|
#define _TESTMBOX_H_
|
||||||
|
|
||||||
|
extern const struct testcase *patternmbox[];
|
||||||
|
|
||||||
|
#endif /* _TESTMBOX_H_ */
|
|
@ -56,7 +56,7 @@ static void mtx1_execute(void) {
|
||||||
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
|
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
|
||||||
chMtxUnlock();
|
chMtxUnlock();
|
||||||
test_wait_threads();
|
test_wait_threads();
|
||||||
test_assert(prio == chThdGetPriority(), "priority return failure");
|
test_assert(prio == chThdGetPriority(), "#1"); /* Priority return failure.*/
|
||||||
test_assert_sequence("ABCDE");
|
test_assert_sequence("ABCDE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,10 @@ static void pools1_execute(void) {
|
||||||
|
|
||||||
/* Empting the pool again. */
|
/* Empting the pool again. */
|
||||||
for (i = 0; i < MAX_THREADS; i++)
|
for (i = 0; i < MAX_THREADS; i++)
|
||||||
test_assert(chPoolAlloc(&mp1) != NULL, "pool list empty");
|
test_assert(chPoolAlloc(&mp1) != NULL, "#1"); /* Pool list empty.*/
|
||||||
|
|
||||||
/* Now must be empty. */
|
/* Now must be empty. */
|
||||||
test_assert(chPoolAlloc(&mp1) == NULL, "pool list not empty");
|
test_assert(chPoolAlloc(&mp1) == NULL, "#2"); /* Pool list not empty.*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct testcase testpools1 = {
|
const struct testcase testpools1 = {
|
||||||
|
|
|
@ -86,8 +86,8 @@ static void sem2_execute(void) {
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
test_emit_token('A' + i);
|
test_emit_token('A' + i);
|
||||||
chSemWaitTimeout(&sem1, MS2ST(500));
|
chSemWaitTimeout(&sem1, MS2ST(500));
|
||||||
test_assert(isempty(&sem1.s_queue), "queue not empty");
|
test_assert(isempty(&sem1.s_queue), "#1"); /* Queue not empty */
|
||||||
test_assert(&sem1.s_cnt != 0, "counter not zero");
|
test_assert(&sem1.s_cnt != 0, "#2"); /* Counter not zero */
|
||||||
}
|
}
|
||||||
test_assert_sequence("ABCDE");
|
test_assert_sequence("ABCDE");
|
||||||
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
|
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
|
||||||
|
|
17
todo.txt
17
todo.txt
|
@ -1,27 +1,22 @@
|
||||||
After 1.0.0:
|
After 1.0.0:
|
||||||
X Improve makefiles by adding an options head section and making it shared.
|
X Improve makefiles by adding an options head section and making it shared.
|
||||||
- Update C++ wrapper (Heap, Pools).
|
* Queues macros should not refer to the semaphore counters directly.
|
||||||
* Priority ordering option for semaphores.
|
* Priority ordering option for semaphores.
|
||||||
* chSysLock() and chSysUnlock() with counter (option).
|
* chSysLock() and chSysUnlock() with counter (option).
|
||||||
* OSEK-style chSysSuspendAll()/chSysResumeAll()/chSysEnable()/chSysDisable(),
|
* OSEK-style chSysSuspendAll()/chSysResumeAll()/chSysEnable()/chSysDisable(),
|
||||||
implemented this as the new Suspended and Disabled states in 1.1.
|
implemented this as the new Suspended and Disabled states in 1.1.
|
||||||
X lwIP TCP/IP stack integration and demo.
|
* Mailboxes subsystem (lwIP requires them).
|
||||||
X "Wide Queues" or Mailboxes, lwIP requires them.
|
|
||||||
X FatFS library integration and demo.
|
|
||||||
* Multiple debug switches.
|
* Multiple debug switches.
|
||||||
X Stack checks option.
|
X Stack checks option.
|
||||||
* Threads profiling option.
|
* Threads profiling option.
|
||||||
- Objects registry.
|
|
||||||
* Idle loop hook macro.
|
* Idle loop hook macro.
|
||||||
* Switch the configuration options to TRUE/FALSE rather than def/undef.
|
* Switch the configuration options to TRUE/FALSE rather than def/undef.
|
||||||
|
|
||||||
|
After 1.2.0:
|
||||||
- Threads Pools manager in the library.
|
- Threads Pools manager in the library.
|
||||||
- New chThdCreate() that takes just two parameters, a pointer to a thread
|
- New chThdCreate() that takes just two parameters, a pointer to a thread
|
||||||
descriptor and the tread parameter. It could wrap the current variants
|
descriptor and the tread parameter. It could wrap the current variants
|
||||||
or just be an alternative.
|
or just be an alternative.
|
||||||
- Fix the names of the Queues macros, also do not refer to the semaphore
|
|
||||||
counters directly.
|
|
||||||
|
|
||||||
After 1.2.0:
|
|
||||||
- Minimal optional C-runtime library (complete enough for lwIP).
|
- Minimal optional C-runtime library (complete enough for lwIP).
|
||||||
- OSEK-style simple tasks within the idle thread.
|
- OSEK-style simple tasks within the idle thread.
|
||||||
- Think to something for threads restart.
|
- Think to something for threads restart.
|
||||||
|
@ -30,6 +25,7 @@ After 1.2.0:
|
||||||
- Move the serial drivers implementations in library al keep the I/O channel
|
- Move the serial drivers implementations in library al keep the I/O channel
|
||||||
interface as part of the kernel. Better keep the core as compact as
|
interface as part of the kernel. Better keep the core as compact as
|
||||||
possible.
|
possible.
|
||||||
|
- Update C++ wrapper (Heap, Pools, Mailboxes and any new feature).
|
||||||
|
|
||||||
Ideas for 2.x.x:
|
Ideas for 2.x.x:
|
||||||
- Reference counter for threads, concept of detached threads, threads
|
- Reference counter for threads, concept of detached threads, threads
|
||||||
|
@ -38,12 +34,15 @@ Ideas for 2.x.x:
|
||||||
- Multicore support.
|
- Multicore support.
|
||||||
|
|
||||||
Side projects:
|
Side projects:
|
||||||
|
X lwIP TCP/IP stack integration and demo.
|
||||||
|
X FatFS library integration and demo.
|
||||||
X ChibiOS Wizard, UML modeling and ChibiOS applications code and
|
X ChibiOS Wizard, UML modeling and ChibiOS applications code and
|
||||||
documentation generator.
|
documentation generator.
|
||||||
X OSEK layer.
|
X OSEK layer.
|
||||||
- Posix layer.
|
- Posix layer.
|
||||||
X File System
|
X File System
|
||||||
- Visual debugger interfaced to OpenOCD.
|
- Visual debugger interfaced to OpenOCD.
|
||||||
|
- Objects registry.
|
||||||
|
|
||||||
Lower priority:
|
Lower priority:
|
||||||
- More demos
|
- More demos
|
||||||
|
|
Loading…
Reference in New Issue