git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@437 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2008-09-22 15:29:48 +00:00
parent 9b2c9869dd
commit 9a1c91e6ee
21 changed files with 283 additions and 66 deletions

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
//#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
//#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -147,6 +147,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -148,6 +148,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -148,6 +148,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -260,7 +260,8 @@ PREDEFINED = __JUST_STUBS__ \
CH_USE_MESSAGES_EVENT \
CH_USE_MESSAGES_PRIORITY \
CH_USE_DEBUG \
CH_USE_TRACE
CH_USE_TRACE \
CH_USE_DYNAMIC
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------

View File

@ -75,13 +75,16 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
*****************************************************************************
*** 0.7.1 ***
- NEW: New chThdInit() API, this API allows to quickly create threads in the
PRSUSPENDED state. This API also allows to start threads from interrupt
handlers.
- CHANGE: The chThdCreate() API no more has the mode parameter, a different
API is now used in order to start suspended threads.
- NEW: New chThdInit() and chThdCreateStatic() APIs now replace the old
chThdCreate() and chThdCreateFast() that are marked as deprecated.
The new APIs use one less parameter and are faster.
- NEW: New dynamic chThdCreateFromHeap() and chthdCreateFromMemoryPool() APIs.
The dynamic APIs are only included if the CH_USE_DYNAMIC option is specified
into the project configuration file.
- FIX: The chThdCreate() had a regression in 0.7.0, the mode parameter was
ignored. Note that in this version the mode parameter had been removed.
ignored. Note that in this version the API is deprecated and the bug
documented as correct behavior. If you need to create a suspended thread
please use the new chThdInit() API.
*** 0.7.0 ***
- NEW: Memory Heap Allocator functionality added. The allocator implements a

View File

@ -49,7 +49,7 @@ void chSysInit(void) {
/*
* Now this instructions flow becomes the main thread.
*/
init_thread(NORMALPRIO, &mainthread);
init_thread(&mainthread, NORMALPRIO);
mainthread.p_state = PRCURR;
currp = &mainthread;
@ -61,8 +61,8 @@ void chSysInit(void) {
* serve interrupts in its context while keeping the lowest energy saving
* mode compatible with the system status.
*/
chThdCreateFast(IDLEPRIO, waIdleThread, sizeof(waIdleThread),
(tfunc_t)_IdleThread);
chThdCreateStatic(waIdleThread, sizeof(waIdleThread),
IDLEPRIO, (tfunc_t)_IdleThread, NULL);
}
/**

View File

@ -27,7 +27,7 @@
/*
* Initializes a thread structure.
*/
void init_thread(tprio_t prio, Thread *tp) {
void init_thread(Thread *tp, tprio_t prio) {
static tid_t nextid = 0;
tp->p_tid = nextid++;
@ -83,8 +83,8 @@ static void memfill(uint8_t *p, uint32_t n, uint8_t v) {
* @note This function can be used to start a thead from within an interrupt
* handler by manually making it ready with \p chSchReadyI().
*/
Thread *chThdInit(tprio_t prio, void *workspace,
size_t wsize, tfunc_t pf, void *arg) {
Thread *chThdInit(void *workspace, size_t wsize,
tprio_t prio, tfunc_t pf, void *arg) {
/* thread structure is layed out in the lower part of the thread workspace */
Thread *tp = workspace;
@ -95,15 +95,114 @@ Thread *chThdInit(tprio_t prio, void *workspace,
memfill(workspace, wsize, MEM_FILL_PATTERN);
#endif
SETUP_CONTEXT(workspace, wsize, pf, arg);
init_thread(prio, tp);
init_thread(tp, prio);
return tp;
}
/**
* Creates a new thread into a static memory area.
* @param workspace pointer to a working area dedicated to the thread stack
* @param wsize size of the working area.
* @param prio the priority level for the new thread. Usually the threads are
* created with priority \p NORMALPRIO, priorities
* can range from \p LOWPRIO to \p HIGHPRIO.
* @param pf the thread function. Returning from this function automatically
* terminates the thread.
* @param arg an argument passed to the thread function. It can be \p NULL.
* @return the pointer to the \p Thread structure allocated for the
* thread into the working space area.
* @note A thread can terminate by calling \p chThdExit() or by simply
* returning from its main function.
*/
Thread *chThdCreateStatic(void *workspace, size_t wsize,
tprio_t prio, tfunc_t pf, void *arg) {
Thread *tp = chThdInit(workspace, wsize, prio, pf, arg);
chSysLock();
chSchWakeupS(tp, RDY_OK);
chSysUnlock();
return tp;
}
#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_HEAP)
/**
* Creates a new thread allocating the memory from the heap.
* @param wsize size of the working area to be allocated
* @param prio the priority level for the new thread. Usually the threads are
* created with priority \p NORMALPRIO, priorities
* can range from \p LOWPRIO to \p HIGHPRIO.
* @param pf the thread function. Returning from this function automatically
* terminates the thread.
* @param arg an argument passed to the thread function. It can be \p NULL.
* @return the pointer to the \p Thread structure allocated for the
* thread into the working space area or \p NULL if the memory cannot
* be allocated.
* @note A thread can terminate by calling \p chThdExit() or by simply
* returning from its main function.
* @note The memory allocated for the thread is not released when the thread
* terminates but when a \p chThdWait() is performed.
* @note The function is available only if the \p CH_USE_DYNAMIC,
* \p CH_USE_HEAP and \p CH_USE_WAITEXIT options are enabled
* in \p chconf.h.
*/
Thread *chThdCreateFromHeap(size_t wsize, tprio_t prio,
tfunc_t pf, void *arg) {
void *workspace = chHeapAlloc(wsize);
if (workspace == NULL)
return NULL;
Thread *tp = chThdInit(workspace, wsize, prio, pf, arg);
tp->p_flags |= P_MEM_MODE_HEAP;
chSysLock();
chSchWakeupS(tp, RDY_OK);
chSysUnlock();
return tp;
}
#endif /* defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_HEAP) */
#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_MEMPOOLS)
/**
* Creates a new thread allocating the memory from the specified Memory Pool.
* @param mp the memory pool
* @param prio the priority level for the new thread. Usually the threads are
* created with priority \p NORMALPRIO, priorities
* can range from \p LOWPRIO to \p HIGHPRIO.
* @param pf the thread function. Returning from this function automatically
* terminates the thread.
* @param arg an argument passed to the thread function. It can be \p NULL.
* @return the pointer to the \p Thread structure allocated for the
* thread into the working space area or \p NULL if the memory cannot
* be allocated.
* @note A thread can terminate by calling \p chThdExit() or by simply
* returning from its main function.
* @note The memory allocated for the thread is not released when the thread
* terminates but when a \p chThdWait() is performed.
* @note The function is available only if the \p CH_USE_DYNAMIC,
* \p CH_USE_MEMPOOLS and \p CH_USE_WAITEXIT options are enabled
* in \p chconf.h.
*/
Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
tfunc_t pf, void *arg) {
void *workspace = chPoolAlloc(mp);
if (workspace == NULL)
return NULL;
Thread *tp = chThdInit(workspace, mp->mp_object_size, prio, pf, arg);
tp->p_flags |= P_MEM_MODE_MEMPOOL;
tp->p_mpool = mp;
chSysLock();
chSchWakeupS(tp, RDY_OK);
chSysUnlock();
return tp;
}
#endif /* defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_MEMPOOLS) */
/**
* Creates a new thread.
* @param prio the priority level for the new thread. Usually the threads are
* created with priority \p NORMALPRIO, priorities
* can range from \p LOWPRIO to \p HIGHPRIO.
* @param mode ignored
* @param workspace pointer to a working area dedicated to the thread stack
* @param wsize size of the working area.
* @param pf the thread function. Returning from this function automatically
@ -113,15 +212,13 @@ Thread *chThdInit(tprio_t prio, void *workspace,
* thread into the working space area.
* @note A thread can terminate by calling \p chThdExit() or by simply
* returning from its main function.
* @deprecated Please use \p chThdCreateStatic() or \p chThdInit() instead,
* this function will be removed in version 1.0.0.
*/
Thread *chThdCreate(tprio_t prio, void *workspace,
Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
size_t wsize, tfunc_t pf, void *arg) {
Thread *tp = chThdInit(prio, workspace, wsize, pf, arg);
chSysLock();
chSchWakeupS(tp, RDY_OK);
chSysUnlock();
return tp;
return chThdCreateStatic(workspace, wsize, prio, pf, arg);
}
/**
@ -137,16 +234,13 @@ Thread *chThdCreate(tprio_t prio, void *workspace,
* thread into the working space area.
* @note A thread can terminate by calling \p chThdExit() or by simply
* returning from its main function.
* @deprecated
* @deprecated Please use \p chThdCreateStatic() or \p chThdInit() instead,
* this function will be removed in version 1.0.0.
*/
Thread *chThdCreateFast(tprio_t prio, void *workspace,
size_t wsize, tfunc_t pf) {
Thread *tp = chThdInit(prio, workspace, wsize, pf, NULL);
chSysLock();
chSchWakeupS(tp, RDY_OK);
chSysUnlock();
return tp;
return chThdCreateStatic(workspace, wsize, prio, pf, NULL);
}
/**
@ -245,9 +339,21 @@ void chThdExit(msg_t msg) {
/**
* Blocks the execution of the invoking thread until the specified thread
* terminates then the exit code is returned.
*
* @param tp the pointer to the thread
* @return the exit code
* The memory used by the exited thread is handled in different ways depending
* on the API that spawned the thread:
* <ul>
* <li>If the thread was spawned by \p chThdCreateStatic() or by \p chThdInit()
* then nothing happens and the thread working area is not released or
* modified in any way. This is the default, totally static, behavior.</li>
* <li>If the thread was spawned by \p chThdCreateFromHeap() then the working
* area is returned to the system heap.</li>
* <li>If the thread was spawned by \p chThdCreateFromMemoryPool() then the
* working area is returned to the owning memory pool.</li>
* </ul>
* @param tp the thread pointer
* @return the exit code from the terminated thread
* @note After invoking \p chThdWait() the thread pointer becomes invalid and
* must not be used as parameter for further system calls.
* @note The function is available only if the \p CH_USE_WAITEXIT
* option is enabled in \p chconf.h.
*/
@ -262,8 +368,33 @@ msg_t chThdWait(Thread *tp) {
}
msg = tp->p_exitcode;
#ifndef CH_USE_DYNAMIC
chSysUnlock();
return msg;
#else /* CH_USE_DYNAMIC */
if (notempty(&tp->p_waiting)) {
chSysUnlock();
return msg;
}
/* This is the last thread waiting for termination, returning memory.*/
tmode_t mode = tp->p_flags & P_MEM_MODE_MASK;
chSysUnlock();
switch (mode) {
#ifdef CH_USE_HEAP
case P_MEM_MODE_HEAP:
chHeapFree(tp);
break;
#endif
#ifdef CH_USE_MEMPOOLS
case P_MEM_MODE_MEMPOOL:
chPoolFree(tp->p_mpool, tp);
break;
#endif
}
return msg;
#endif /* CH_USE_DYNAMIC */
}
#endif /* CH_USE_WAITEXIT */

View File

@ -37,13 +37,13 @@
#include "mutexes.h"
#include "events.h"
#include "messages.h"
#include "heap.h"
#include "mempools.h"
#include "threads.h"
#include "inline.h"
#include "sleep.h"
#include "queues.h"
#include "serial.h"
#include "heap.h"
#include "mempools.h"
#include "debug.h"
/*

View File

@ -106,6 +106,10 @@ struct Thread {
/** Thread's own, non-inherited, priority. */
tprio_t p_realprio;
#endif
#if defined(CH_USE_DYNAMIC) && defined(CH_USE_MEMPOOLS)
/** Memory Pool where the thread workspace is returned. */
void *p_mpool;
#endif
#ifdef CH_USE_THREAD_EXT
THREAD_EXT_FIELDS
#endif
@ -134,8 +138,14 @@ struct Thread {
/** Thread state: After termination.*/
#define PREXIT 10
/** Thread option: Termination requested flag.*/
#define P_TERMINATE 1
/*
* Various flags into the thread p_flags field.
*/
#define P_MEM_MODE_MASK 3 /* Thread memory mode mask. */
#define P_MEM_MODE_STATIC 0 /* Thread memory mode: static. */
#define P_MEM_MODE_HEAP 1 /* Thread memory mode: heap. */
#define P_MEM_MODE_MEMPOOL 2 /* Thread memory mode: mempool. */
#define P_TERMINATE 4 /* Termination requested. */
/** Pseudo priority used by the ready list header, do not use.*/
#define NOPRIO 0
@ -151,7 +161,7 @@ struct Thread {
#define ABSPRIO 255
/* Not an API, don't use into the application code.*/
void init_thread(tprio_t prio, Thread *tp);
void init_thread(Thread *tp, tprio_t prio);
/** Thread function.*/
typedef msg_t (*tfunc_t)(void *);
@ -162,9 +172,15 @@ typedef msg_t (*tfunc_t)(void *);
#ifdef __cplusplus
extern "C" {
#endif
Thread *chThdInit(tprio_t prio, void *workspace,
size_t wsize, tfunc_t pf, void *arg);
Thread *chThdCreate(tprio_t prio, void *workspace,
Thread *chThdInit(void *workspace, size_t wsize,
tprio_t prio, tfunc_t pf, void *arg);
Thread *chThdCreateStatic(void *workspace, size_t wsize,
tprio_t prio, tfunc_t pf, void *arg);
Thread *chThdCreateFromHeap(size_t wsize, tprio_t prio,
tfunc_t pf, void *arg);
Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
tfunc_t pf, void *arg);
Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
size_t wsize, tfunc_t pf, void *arg);
Thread *chThdCreateFast(tprio_t prio, void *workspace,
size_t wsize, tfunc_t pf);

View File

@ -148,6 +148,12 @@
* are included in the kernel.*/
#define CH_USE_MEMPOOLS
/** Configuration option: if specified then the dynamic objects creation APIs
* are included in the kernel.
* @note requires \p CH_USE_WAITEXIT.
*/
#define CH_USE_DYNAMIC
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000

View File

@ -47,7 +47,7 @@ static msg_t thread(void *p) {
static void msg1_execute(void) {
msg_t msg;
threads[0] = chThdCreate(chThdGetPriority()-1, wa[0], STKSIZE, thread, chThdSelf());
threads[0] = chThdCreateStatic(wa[0], STKSIZE, chThdGetPriority()-1, thread, chThdSelf());
do {
chMsgRelease(msg = chMsgWait());
if (msg)

View File

@ -52,11 +52,11 @@ static void mtx1_execute(void) {
tprio_t prio = chThdGetPriority(); // Bacause priority inheritance.
chMtxLock(&m1);
threads[0] = chThdCreate(prio+1, wa[0], STKSIZE, thread1, "E");
threads[1] = chThdCreate(prio+2, wa[1], STKSIZE, thread1, "D");
threads[2] = chThdCreate(prio+3, wa[2], STKSIZE, thread1, "C");
threads[3] = chThdCreate(prio+4, wa[3], STKSIZE, thread1, "B");
threads[4] = chThdCreate(prio+5, wa[4], STKSIZE, thread1, "A");
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");
chMtxUnlock();
test_assert(prio == chThdGetPriority(), "priority return failure");
test_wait_threads();
@ -117,9 +117,9 @@ static msg_t thread4(void *p) {
*/
static void mtx2_execute(void) {
threads[0] = chThdCreate(chThdGetPriority()-1, wa[0], STKSIZE, thread2, "A");
threads[1] = chThdCreate(chThdGetPriority()-3, wa[1], STKSIZE, thread3, "C");
threads[2] = chThdCreate(chThdGetPriority()-2, wa[2], STKSIZE, thread4, "B");
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");
test_wait_threads();
test_assert_sequence("ABC");
}
@ -206,11 +206,11 @@ static msg_t thread9(void *p) {
*/
static void mtx3_execute(void) {
threads[0] = chThdCreate(chThdGetPriority()-5, wa[0], STKSIZE, thread5, "E");
threads[1] = chThdCreate(chThdGetPriority()-4, wa[1], STKSIZE, thread6, "D");
threads[2] = chThdCreate(chThdGetPriority()-3, wa[2], STKSIZE, thread7, "C");
threads[3] = chThdCreate(chThdGetPriority()-2, wa[3], STKSIZE, thread8, "B");
threads[4] = chThdCreate(chThdGetPriority()-1, wa[4], STKSIZE, thread9, "A");
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");
test_wait_threads();
test_assert_sequence("ABCDE");
}

View File

@ -40,11 +40,11 @@ static void rdy1_teardown(void) {
static void rdy1_execute(void) {
threads[0] = chThdCreate(chThdGetPriority()-5, wa[0], STKSIZE, thread, "E");
threads[1] = chThdCreate(chThdGetPriority()-4, wa[1], STKSIZE, thread, "D");
threads[2] = chThdCreate(chThdGetPriority()-3, wa[2], STKSIZE, thread, "C");
threads[3] = chThdCreate(chThdGetPriority()-2, wa[3], STKSIZE, thread, "B");
threads[4] = chThdCreate(chThdGetPriority()-1, wa[4], STKSIZE, thread, "A");
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");
test_wait_threads();
test_assert_sequence("ABCDE");
}
@ -69,11 +69,11 @@ static void rdy2_teardown(void) {
static void rdy2_execute(void) {
threads[1] = chThdCreate(chThdGetPriority()-4, wa[1], STKSIZE, thread, "D");
threads[0] = chThdCreate(chThdGetPriority()-5, wa[0], STKSIZE, thread, "E");
threads[4] = chThdCreate(chThdGetPriority()-1, wa[4], STKSIZE, thread, "A");
threads[3] = chThdCreate(chThdGetPriority()-2, wa[3], STKSIZE, thread, "B");
threads[2] = chThdCreate(chThdGetPriority()-3, wa[2], STKSIZE, thread, "C");
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");
test_wait_threads();
test_assert_sequence("ABCDE");
}

View File

@ -47,11 +47,11 @@ static msg_t thread(void *p) {
static void sem1_execute(void) {
threads[0] = chThdCreate(chThdGetPriority()+5, wa[0], STKSIZE, thread, "A");
threads[1] = chThdCreate(chThdGetPriority()+1, wa[1], STKSIZE, thread, "B");
threads[2] = chThdCreate(chThdGetPriority()+3, wa[2], STKSIZE, thread, "C");
threads[3] = chThdCreate(chThdGetPriority()+4, wa[3], STKSIZE, thread, "D");
threads[4] = chThdCreate(chThdGetPriority()+2, wa[4], STKSIZE, thread, "E");
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");
chSemSignal(&sem1);
chSemSignal(&sem1);
chSemSignal(&sem1);