From b3e92dc72078603137a7182759419e2b801755b9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 29 Nov 2008 10:54:24 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@521 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-AT91SAM7X-GCC/main.c | 2 +- demos/ARM7-LPC214x-GCC/main.c | 6 ++--- ports/ARM7-AT91SAM7X/chcore.c | 2 +- ports/ARM7-LPC214x/chcore.c | 2 +- ports/ARM7/chcore.h | 33 ++++++++++++++++++------- readme.txt | 5 ++++ src/chinit.c | 5 ++-- src/chthreads.c | 2 +- src/templates/chcore.c | 10 +++++++- src/templates/chcore.h | 53 +++++++++++++++++++++++++++++------------ test/test.c | 10 ++++---- test/test.h | 2 +- test/testbmk.c | 28 +++++++++++----------- test/testcond.c | 20 ++++++++-------- test/testdyn.c | 6 ++--- test/testmsg.c | 2 +- test/testmtx.c | 26 ++++++++++---------- test/testpools.c | 2 +- test/testrdy.c | 20 ++++++++-------- test/testsem.c | 10 ++++---- 20 files changed, 149 insertions(+), 97 deletions(-) diff --git a/demos/ARM7-AT91SAM7X-GCC/main.c b/demos/ARM7-AT91SAM7X-GCC/main.c index 1d60db848..c51c911c9 100644 --- a/demos/ARM7-AT91SAM7X-GCC/main.c +++ b/demos/ARM7-AT91SAM7X-GCC/main.c @@ -23,7 +23,7 @@ #include "board.h" #include -static WorkingArea(waThread1, 64); +static WORKING_AREA(waThread1, 64); static msg_t Thread1(void *arg) { while (TRUE) { diff --git a/demos/ARM7-LPC214x-GCC/main.c b/demos/ARM7-LPC214x-GCC/main.c index 90dece112..96b117f8a 100644 --- a/demos/ARM7-LPC214x-GCC/main.c +++ b/demos/ARM7-LPC214x-GCC/main.c @@ -29,7 +29,7 @@ /* * Red LEDs blinker thread, times are in milliseconds. */ -static WorkingArea(waThread1, 64); +static WORKING_AREA(waThread1, 64); static msg_t Thread1(void *arg) { while (TRUE) { @@ -48,7 +48,7 @@ static msg_t Thread1(void *arg) { /* * Yellow LED blinker thread, times are in milliseconds. */ -static WorkingArea(waThread2, 64); +static WORKING_AREA(waThread2, 64); static msg_t Thread2(void *arg) { while (TRUE) { @@ -60,7 +60,7 @@ static msg_t Thread2(void *arg) { return 0; } -static WorkingArea(waTestThread, 128); +static WORKING_AREA(waTestThread, 128); /* * Executed as event handler at 500mS intervals. diff --git a/ports/ARM7-AT91SAM7X/chcore.c b/ports/ARM7-AT91SAM7X/chcore.c index af8bad20f..709db25be 100644 --- a/ports/ARM7-AT91SAM7X/chcore.c +++ b/ports/ARM7-AT91SAM7X/chcore.c @@ -24,7 +24,7 @@ /* * System idle thread loop. */ -void _IdleThread(void *p) { +void _idle(void *p) { while (TRUE) { // Note, it is disabled because it causes trouble with the JTAG probe. diff --git a/ports/ARM7-LPC214x/chcore.c b/ports/ARM7-LPC214x/chcore.c index 8803c47e3..01f3e2d68 100644 --- a/ports/ARM7-LPC214x/chcore.c +++ b/ports/ARM7-LPC214x/chcore.c @@ -24,7 +24,7 @@ /* * System idle thread loop. */ -void _IdleThread(void *p) { +void _idle(void *p) { while (TRUE) { // Note, it is disabled because it causes trouble with the JTAG probe. diff --git a/ports/ARM7/chcore.h b/ports/ARM7/chcore.h index daf8df77c..86f138669 100644 --- a/ports/ARM7/chcore.h +++ b/ports/ARM7/chcore.h @@ -20,8 +20,16 @@ #ifndef _CHCORE_H_ #define _CHCORE_H_ +/** + * Macro defining the ARM7 architecture. + */ #define CH_ARCHITECTURE_ARM7 +/* + * 32 bit stack alignment. + */ +typedef uint32_t stkalign_t; + typedef void *regarm; /* @@ -113,13 +121,22 @@ extern "C" { #else /* !THUMB */ #define INT_REQUIRED_STACK 0 #endif /* !THUMB */ -#define StackAlign(n) ((((n) - 1) | 3) + 1) -#define UserStackSize(n) StackAlign(sizeof(Thread) + \ - sizeof(struct intctx) + \ - sizeof(struct extctx) + \ - (n) + \ - INT_REQUIRED_STACK) -#define WorkingArea(s, n) uint32_t s[UserStackSize(n) >> 2]; + +/* + * Enforces a 32 bit alignment for a stack area size value. + */ +#define STACK_ALIGN(n) ((((n) - 1) | sizeof(stkalign_t)) + 1) + +#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \ + sizeof(struct intctx) + \ + sizeof(struct extctx) + \ + (n) + \ + INT_REQUIRED_STACK) + +/* + * Declares a 32bit aligned thread working area. + */ +#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n)]; #ifdef THUMB #define chSysSwitchI chSysSwitchI_thumb @@ -154,7 +171,7 @@ extern "C" { #ifdef __cplusplus extern "C" { #endif - void _IdleThread(void *p) __attribute__((noreturn)); + void _idle(void *p) __attribute__((weak, noreturn)); void chSysHalt(void); void chSysSwitchI(Thread *otp, Thread *ntp); void chSysPuts(char *msg); diff --git a/readme.txt b/readme.txt index 1fb359a87..ab7b6b182 100644 --- a/readme.txt +++ b/readme.txt @@ -77,6 +77,11 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process, - FIX: Duplicated sections in the documentation removed. - NEW: Added chPoolAllocI() and chPoolFreeI() APIs in order to allow the use of memory pools from interrupt handlers and timer callbacks. +- CHANGE: The macros WorkingArea(), UserStackSize() and StackAlign() are now + deprecated and will be removed in version 1.0.0. Use the new equivalents + WORKING_AREA(), THD_WA_SIZE() and STACK_ALIGN() instead. +- CHANGE: Renamed the default idle thread function from _IdleThread() to + _idle(). *** 0.8.1 *** - FIX: Fixed a regression in version 0.8.0, the configuration switch diff --git a/src/chinit.c b/src/chinit.c index d93ac1581..a675d6910 100644 --- a/src/chinit.c +++ b/src/chinit.c @@ -33,7 +33,7 @@ */ void chSysInit(void) { static Thread mainthread; - static WorkingArea(waIdleThread, IDLE_THREAD_STACK_SIZE); + static WORKING_AREA(idle_wa, IDLE_THREAD_STACK_SIZE); chSchInit(); chDbgInit(); @@ -54,8 +54,7 @@ void chSysInit(void) { * serve interrupts in its context while keeping the lowest energy saving * mode compatible with the system status. */ - chThdCreateStatic(waIdleThread, sizeof(waIdleThread), - IDLEPRIO, (tfunc_t)_IdleThread, NULL); + chThdCreateStatic(idle_wa, sizeof(idle_wa), IDLEPRIO, (tfunc_t)_idle, NULL); } /** diff --git a/src/chthreads.c b/src/chthreads.c index f2afdac89..394da5d2a 100644 --- a/src/chthreads.c +++ b/src/chthreads.c @@ -85,7 +85,7 @@ Thread *chThdInit(void *workspace, size_t wsize, /* thread structure is layed out in the lower part of the thread workspace */ Thread *tp = workspace; - chDbgAssert((wsize >= UserStackSize(0)) && (prio <= HIGHPRIO) && + chDbgAssert((wsize >= THD_WA_SIZE(0)) && (prio <= HIGHPRIO) && (workspace != NULL) && (pf != NULL), "chthreads.c, chThdInit()"); #ifdef CH_USE_DEBUG diff --git a/src/templates/chcore.c b/src/templates/chcore.c index 95427c161..40dd4315b 100644 --- a/src/templates/chcore.c +++ b/src/templates/chcore.c @@ -35,8 +35,10 @@ * put the processor in the lowest power mode capable to serve interrupts. * The priority is internally set to the minimum system value so that this * thread is executed only if there are no other ready threads in the system. + * @note Implementation should declare this function as a weak symbol in order + * to allow applications to re-implement it. */ -void _IdleThread(void *p) { +void _idle(void *p) { while (TRUE) ; @@ -54,6 +56,12 @@ void chSysHalt(void) { ; } +/** + * Enables the interrupts, it is only invoked once into \p chSysInit(). + */ +void chSysEnable(void) { +} + /** * Enters the ChibiOS/RT system mutual exclusion zone. The implementation is * architecture dependent, on single core systems usually this function usually diff --git a/src/templates/chcore.h b/src/templates/chcore.h index 1be2d7145..663033fb5 100644 --- a/src/templates/chcore.h +++ b/src/templates/chcore.h @@ -30,6 +30,11 @@ */ #define CH_ARCHITECTURE_XXX +/** + * Base type for stack alignment. + */ +typedef uint8_t stkalign_t; + /** * Interrupt saved context. */ @@ -59,38 +64,55 @@ typedef struct { #define IDLE_THREAD_STACK_SIZE 0 /** - * Per-thread stack overhead for interrupts servicing. + * Per-thread stack overhead for interrupts servicing, it is used in the + * calculation of the correct working area size. */ #define INT_REQUIRED_STACK 0 /** - * Enforces a stack size alignment. + * Enforces a correct alignment for a stack area size value. + * @deprecated Use STACK_ALIGN() instead, this macro will be removed in + * version 1.0.0. + */ +#define StackAlign(n) STACK_ALIGN(n) + +/** + * Enforces a correct alignment for a stack area size value. */ -#define StackAlign(n) (n) +#define STACK_ALIGN(n) ((((n) - 1) | sizeof(stkalign_t)) + 1) /** - * Macro to be used when allocating stack spaces, it adds the system-specific - * overhead. + * Computes the thread working area global size. + * @deprecated Use THD_WA_SIZE() instead, this macro will be removed in + * version 1.0.0. */ -#define UserStackSize(n) StackAlign(sizeof(Thread) + \ - sizeof(struct intctx) + \ - sizeof(struct extctx) + \ - (n) + (INT_REQUIRED_STACK)) +#define UserStackSize(n) THD_WA_SIZE(n) + + /** + * Computes the thread working area global size. + */ +#define THD_WA_SIZE(n) StackAlign(sizeof(Thread) + \ + sizeof(struct intctx) + \ + sizeof(struct extctx) + \ + (n) + (INT_REQUIRED_STACK)) /** * Macro used to allocate a thread working area aligned as both position and * size. + * @deprecated Use WORKING_AREA() instead, this macro will be removed in + * version 1.0.0. */ -#define WorkingArea(s, n) uint8_t s[UserStackSize(n)]; +#define WorkingArea(s, n) WORKING_AREA(s, n) /** - * Enables the interrupts, it is only invoked once into \p chSysInit(). + * Macro used to allocate a thread working area aligned as both position and + * size. */ -#define chSysEnable() +#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n)]; /** * IRQ handler enter code. - * @note Usually IRQ handlers function are also declared naked. + * @note Usually IRQ handlers functions are also declared naked. * @note On some architectures this macro can be empty. */ #define chSysIRQEnterI() @@ -98,7 +120,7 @@ typedef struct { /** * IRQ handler exit code. * @note Usually IRQ handlers function are also declared naked. - * @note This macro must perform the final reschedulation by using + * @note This macro usually performs the final reschedulation by using * \p chSchRescRequiredI() and \p chSchDoRescheduleI(). */ #define chSysIRQExitI() @@ -106,8 +128,9 @@ typedef struct { #ifdef __cplusplus extern "C" { #endif - void _IdleThread(void *p); + void _idle(void *p); void chSysHalt(void); + void chSysEnable(void); void chSysLock(void); void chSysUnlock(void); void chSysSwitchI(Thread *otp, Thread *ntp); diff --git a/test/test.c b/test/test.c index b603a20b8..83be7410a 100644 --- a/test/test.c +++ b/test/test.c @@ -83,11 +83,11 @@ static bool_t local_fail, global_fail; static char *failmsg; static char tokens_buffer[MAX_TOKENS]; static char *tokp; -static WorkingArea(waT0, THREADS_STACK_SIZE); -static WorkingArea(waT1, THREADS_STACK_SIZE); -static WorkingArea(waT2, THREADS_STACK_SIZE); -static WorkingArea(waT3, THREADS_STACK_SIZE); -static WorkingArea(waT4, THREADS_STACK_SIZE); +static WORKING_AREA(waT0, THREADS_STACK_SIZE); +static WORKING_AREA(waT1, THREADS_STACK_SIZE); +static WORKING_AREA(waT2, THREADS_STACK_SIZE); +static WORKING_AREA(waT3, THREADS_STACK_SIZE); +static WORKING_AREA(waT4, THREADS_STACK_SIZE); void *wa[MAX_THREADS] = {waT0, waT1, waT2, waT3, waT4}; Thread *threads[MAX_THREADS]; diff --git a/test/test.h b/test/test.h index 864b12e4f..fe850faf1 100644 --- a/test/test.h +++ b/test/test.h @@ -29,7 +29,7 @@ #else #define THREADS_STACK_SIZE 128 #endif -#define STKSIZE UserStackSize(THREADS_STACK_SIZE) +#define WA_SIZE THD_WA_SIZE(THREADS_STACK_SIZE) struct testcase { char *(*gettest)(void); diff --git a/test/testbmk.c b/test/testbmk.c index 02b810e1f..19775a2d3 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -59,7 +59,7 @@ static char *bmk1_gettest(void) { static void bmk1_execute(void) { uint32_t n; - threads[0] = chThdCreateFast(chThdGetPriority()-1, wa[0], STKSIZE, thread1); + threads[0] = chThdCreateFast(chThdGetPriority()-1, wa[0], WA_SIZE, thread1); n = msg_loop_test(threads[0]); chThdTerminate(threads[0]); test_wait_threads(); @@ -85,7 +85,7 @@ static char *bmk2_gettest(void) { static void bmk2_execute(void) { uint32_t n; - threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], STKSIZE, thread1); + threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], WA_SIZE, thread1); n = msg_loop_test(threads[0]); chThdTerminate(threads[0]); test_wait_threads(); @@ -116,11 +116,11 @@ static char *bmk3_gettest(void) { static void bmk3_execute(void) { uint32_t n; - threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], STKSIZE, thread1); - threads[1] = chThdCreateFast(chThdGetPriority()-2, wa[1], STKSIZE, thread2); - threads[2] = chThdCreateFast(chThdGetPriority()-3, wa[2], STKSIZE, thread2); - threads[3] = chThdCreateFast(chThdGetPriority()-4, wa[3], STKSIZE, thread2); - threads[4] = chThdCreateFast(chThdGetPriority()-5, wa[4], STKSIZE, thread2); + threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], WA_SIZE, thread1); + threads[1] = chThdCreateFast(chThdGetPriority()-2, wa[1], WA_SIZE, thread2); + threads[2] = chThdCreateFast(chThdGetPriority()-3, wa[2], WA_SIZE, thread2); + threads[3] = chThdCreateFast(chThdGetPriority()-4, wa[3], WA_SIZE, thread2); + threads[4] = chThdCreateFast(chThdGetPriority()-5, wa[4], WA_SIZE, thread2); n = msg_loop_test(threads[0]); chThdTerminate(threads[0]); test_wait_threads(); @@ -151,7 +151,7 @@ static void bmk4_execute(void) { test_wait_tick(); test_start_timer(1000); do { - chThdWait(chThdCreateFast(prio, wap, STKSIZE, thread2)); + chThdWait(chThdCreateFast(prio, wap, WA_SIZE, thread2)); n++; #if defined(WIN32) ChkIntSources(); @@ -182,7 +182,7 @@ static void bmk5_execute(void) { test_wait_tick(); test_start_timer(1000); do { - chThdCreateFast(prio, wap, STKSIZE, thread2); + chThdCreateFast(prio, wap, WA_SIZE, thread2); n++; #if defined(WIN32) ChkIntSources(); @@ -220,11 +220,11 @@ static void bmk6_setup(void) { static void bmk6_execute(void) { uint32_t n; - threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], STKSIZE, thread3); - threads[1] = chThdCreateFast(chThdGetPriority()+2, wa[1], STKSIZE, thread3); - threads[2] = chThdCreateFast(chThdGetPriority()+3, wa[2], STKSIZE, thread3); - threads[3] = chThdCreateFast(chThdGetPriority()+4, wa[3], STKSIZE, thread3); - threads[4] = chThdCreateFast(chThdGetPriority()+5, wa[4], STKSIZE, thread3); + threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], WA_SIZE, thread3); + threads[1] = chThdCreateFast(chThdGetPriority()+2, wa[1], WA_SIZE, thread3); + threads[2] = chThdCreateFast(chThdGetPriority()+3, wa[2], WA_SIZE, thread3); + threads[3] = chThdCreateFast(chThdGetPriority()+4, wa[3], WA_SIZE, thread3); + threads[4] = chThdCreateFast(chThdGetPriority()+5, wa[4], WA_SIZE, thread3); n = 0; test_wait_tick(); diff --git a/test/testcond.c b/test/testcond.c index 07c2a441e..e202a0d15 100644 --- a/test/testcond.c +++ b/test/testcond.c @@ -53,11 +53,11 @@ static void cond1_execute(void) { // Bacause priority inheritance. tprio_t prio = chThdGetPriority(); - threads[0] = chThdCreate(prio+1, 0, wa[0], STKSIZE, thread1, "E"); - threads[1] = chThdCreate(prio+2, 0, wa[1], STKSIZE, thread1, "D"); - threads[2] = chThdCreate(prio+3, 0, wa[2], STKSIZE, thread1, "C"); - threads[3] = chThdCreate(prio+4, 0, wa[3], STKSIZE, thread1, "B"); - threads[4] = chThdCreate(prio+5, 0, wa[4], STKSIZE, thread1, "A"); + threads[0] = chThdCreate(prio+1, 0, wa[0], WA_SIZE, thread1, "E"); + threads[1] = chThdCreate(prio+2, 0, wa[1], WA_SIZE, thread1, "D"); + threads[2] = chThdCreate(prio+3, 0, wa[2], WA_SIZE, thread1, "C"); + threads[3] = chThdCreate(prio+4, 0, wa[3], WA_SIZE, thread1, "B"); + threads[4] = chThdCreate(prio+5, 0, wa[4], WA_SIZE, thread1, "A"); test_assert(prio == chThdGetPriority(), "priority return failure"); chCondSignal(&c1); chCondSignal(&c1); @@ -84,11 +84,11 @@ static void cond2_execute(void) { // Bacause priority inheritance. tprio_t prio = chThdGetPriority(); - threads[0] = chThdCreate(prio+1, 0, wa[0], STKSIZE, thread1, "E"); - threads[1] = chThdCreate(prio+2, 0, wa[1], STKSIZE, thread1, "D"); - threads[2] = chThdCreate(prio+3, 0, wa[2], STKSIZE, thread1, "C"); - threads[3] = chThdCreate(prio+4, 0, wa[3], STKSIZE, thread1, "B"); - threads[4] = chThdCreate(prio+5, 0, wa[4], STKSIZE, thread1, "A"); + threads[0] = chThdCreate(prio+1, 0, wa[0], WA_SIZE, thread1, "E"); + threads[1] = chThdCreate(prio+2, 0, wa[1], WA_SIZE, thread1, "D"); + threads[2] = chThdCreate(prio+3, 0, wa[2], WA_SIZE, thread1, "C"); + threads[3] = chThdCreate(prio+4, 0, wa[3], WA_SIZE, thread1, "B"); + threads[4] = chThdCreate(prio+5, 0, wa[4], WA_SIZE, thread1, "A"); test_assert(prio == chThdGetPriority(), "priority return failure"); chCondBroadcast(&c1); test_wait_threads(); diff --git a/test/testdyn.c b/test/testdyn.c index 0751e052a..37b6b9bc4 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -48,9 +48,9 @@ static void dyn1_execute(void) { /* Test skipped if the heap is already fragmented. */ if ((n = chHeapStatus(&sz)) == 1) { /* Starting threads from the heap. */ - threads[0] = chThdCreateFromHeap(UserStackSize(THREADS_STACK_SIZE), + threads[0] = chThdCreateFromHeap(THD_WA_SIZE(THREADS_STACK_SIZE), prio-1, thread, "A"); - threads[1] = chThdCreateFromHeap(UserStackSize(THREADS_STACK_SIZE), + threads[1] = chThdCreateFromHeap(THD_WA_SIZE(THREADS_STACK_SIZE), prio-2, thread, "B"); test_assert((threads[0] != NULL) && @@ -88,7 +88,7 @@ static char *dyn2_gettest(void) { static void dyn2_setup(void) { - chPoolInit(&mp1, UserStackSize(THREADS_STACK_SIZE)); + chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE)); } static void dyn2_teardown(void) { diff --git a/test/testmsg.c b/test/testmsg.c index fcf811fa1..735375a16 100644 --- a/test/testmsg.c +++ b/test/testmsg.c @@ -47,7 +47,7 @@ static msg_t thread(void *p) { static void msg1_execute(void) { msg_t msg; - threads[0] = chThdCreateStatic(wa[0], STKSIZE, chThdGetPriority()-1, thread, chThdSelf()); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread, chThdSelf()); do { chMsgRelease(msg = chMsgWait()); if (msg) diff --git a/test/testmtx.c b/test/testmtx.c index 0bf69cbf7..4d8df7d02 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -52,11 +52,11 @@ static void mtx1_execute(void) { tprio_t prio = chThdGetPriority(); // Bacause priority inheritance. chMtxLock(&m1); - threads[0] = chThdCreateStatic(wa[0], STKSIZE, prio+1, thread1, "E"); - threads[1] = chThdCreateStatic(wa[1], STKSIZE, prio+2, thread1, "D"); - threads[2] = chThdCreateStatic(wa[2], STKSIZE, prio+3, thread1, "C"); - threads[3] = chThdCreateStatic(wa[3], STKSIZE, prio+4, thread1, "B"); - threads[4] = chThdCreateStatic(wa[4], STKSIZE, prio+5, thread1, "A"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A"); chMtxUnlock(); test_wait_threads(); test_assert(prio == chThdGetPriority(), "priority return failure"); @@ -117,9 +117,9 @@ static msg_t thread4(void *p) { */ static void mtx2_execute(void) { - threads[0] = chThdCreateStatic(wa[0], STKSIZE, chThdGetPriority()-1, thread2, "A"); - threads[1] = chThdCreateStatic(wa[1], STKSIZE, chThdGetPriority()-3, thread3, "C"); - threads[2] = chThdCreateStatic(wa[2], STKSIZE, chThdGetPriority()-2, thread4, "B"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread2, "A"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-3, thread3, "C"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-2, thread4, "B"); test_wait_threads(); test_assert_sequence("ABC"); } @@ -206,11 +206,11 @@ static msg_t thread9(void *p) { */ static void mtx3_execute(void) { - threads[0] = chThdCreateStatic(wa[0], STKSIZE, chThdGetPriority()-5, thread5, "E"); - threads[1] = chThdCreateStatic(wa[1], STKSIZE, chThdGetPriority()-4, thread6, "D"); - threads[2] = chThdCreateStatic(wa[2], STKSIZE, chThdGetPriority()-3, thread7, "C"); - threads[3] = chThdCreateStatic(wa[3], STKSIZE, chThdGetPriority()-2, thread8, "B"); - threads[4] = chThdCreateStatic(wa[4], STKSIZE, chThdGetPriority()-1, thread9, "A"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread5, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread6, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread7, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread8, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread9, "A"); test_wait_threads(); test_assert_sequence("ABCDE"); } diff --git a/test/testpools.c b/test/testpools.c index 2d3ee0f00..d3f451c73 100644 --- a/test/testpools.c +++ b/test/testpools.c @@ -32,7 +32,7 @@ static char *pools1_gettest(void) { static void pools1_setup(void) { - chPoolInit(&mp1, UserStackSize(THREADS_STACK_SIZE)); + chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE)); } static void pools1_teardown(void) { diff --git a/test/testrdy.c b/test/testrdy.c index 2d39e5ff4..a9b52701e 100644 --- a/test/testrdy.c +++ b/test/testrdy.c @@ -40,11 +40,11 @@ static void rdy1_teardown(void) { static void rdy1_execute(void) { - threads[0] = chThdCreateStatic(wa[0], STKSIZE, chThdGetPriority()-5, thread, "E"); - threads[1] = chThdCreateStatic(wa[1], STKSIZE, chThdGetPriority()-4, thread, "D"); - threads[2] = chThdCreateStatic(wa[2], STKSIZE, chThdGetPriority()-3, thread, "C"); - threads[3] = chThdCreateStatic(wa[3], STKSIZE, chThdGetPriority()-2, thread, "B"); - threads[4] = chThdCreateStatic(wa[4], STKSIZE, chThdGetPriority()-1, thread, "A"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A"); test_wait_threads(); test_assert_sequence("ABCDE"); } @@ -69,11 +69,11 @@ static void rdy2_teardown(void) { static void rdy2_execute(void) { - threads[1] = chThdCreateStatic(wa[1], STKSIZE, chThdGetPriority()-4, thread, "D"); - threads[0] = chThdCreateStatic(wa[0], STKSIZE, chThdGetPriority()-5, thread, "E"); - threads[4] = chThdCreateStatic(wa[4], STKSIZE, chThdGetPriority()-1, thread, "A"); - threads[3] = chThdCreateStatic(wa[3], STKSIZE, chThdGetPriority()-2, thread, "B"); - threads[2] = chThdCreateStatic(wa[2], STKSIZE, chThdGetPriority()-3, thread, "C"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C"); test_wait_threads(); test_assert_sequence("ABCDE"); } diff --git a/test/testsem.c b/test/testsem.c index 26c5556f5..72ed6126f 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -49,11 +49,11 @@ static msg_t thread(void *p) { static void sem1_execute(void) { - threads[0] = chThdCreateStatic(wa[0], STKSIZE, chThdGetPriority()+5, thread, "A"); - threads[1] = chThdCreateStatic(wa[1], STKSIZE, chThdGetPriority()+1, thread, "B"); - threads[2] = chThdCreateStatic(wa[2], STKSIZE, chThdGetPriority()+3, thread, "C"); - threads[3] = chThdCreateStatic(wa[3], STKSIZE, chThdGetPriority()+4, thread, "D"); - threads[4] = chThdCreateStatic(wa[4], STKSIZE, chThdGetPriority()+2, thread, "E"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread, "A"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+1, thread, "B"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+4, thread, "D"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+2, thread, "E"); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); -- cgit v1.2.3