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

This commit is contained in:
gdisirio 2008-12-06 10:59:44 +00:00
parent 87befad254
commit d8b450d8a0
4 changed files with 47 additions and 37 deletions

View File

@ -1,5 +1,5 @@
*************************************************************************** ***************************************************************************
Kernel: ChibiOS/RT 0.8.0 Kernel: ChibiOS/RT 0.8.2
Compiler: GCC 3.2.3 (MSPGCC) Compiler: GCC 3.2.3 (MSPGCC)
Options: -O2 -fomit-frame-pointer Options: -O2 -fomit-frame-pointer
Settings: MCLK=DCOCLK 750Khz Settings: MCLK=DCOCLK 750Khz
@ -65,11 +65,11 @@ Settings: MCLK=DCOCLK 750Khz
--- Result: SUCCESS --- Result: SUCCESS
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
--- Test Case 19 (Benchmark, threads creation/termination, worst case) --- Test Case 19 (Benchmark, threads creation/termination, worst case)
--- Score : 1166 threads/S --- Score : 1236 threads/S
--- Result: SUCCESS --- Result: SUCCESS
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
--- Test Case 20 (Benchmark, threads creation/termination, optimal) --- Test Case 20 (Benchmark, threads creation/termination, optimal)
--- Score : 1537 threads/S --- Score : 1560 threads/S
--- Result: SUCCESS --- Result: SUCCESS
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
--- Test Case 21 (Benchmark, mass reschedulation, 5 threads) --- Test Case 21 (Benchmark, mass reschedulation, 5 threads)
@ -84,3 +84,5 @@ Settings: MCLK=DCOCLK 750Khz
--- Score : 5632 timers/S --- Score : 5632 timers/S
--- Result: SUCCESS --- Result: SUCCESS
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Final result: SUCCESS

View File

@ -18,7 +18,7 @@
./ext/ - External libraries or other code not part of ./ext/ - External libraries or other code not part of
ChibiOS/RT but used in the demo applications. ChibiOS/RT but used in the demo applications.
./test/ - Test code, used by some demos. ./test/ - Test code, used by some demos.
./docs/Doxifile - Doxigen project file. ./docs/Doxyfile - Doxygen project file.
./docs/html/index.html - ChibiOS/RT documentation (after running doxigen). ./docs/html/index.html - ChibiOS/RT documentation (after running doxigen).
The documentation is also available on the project The documentation is also available on the project
web page: http://chibios.sourceforge.net/ web page: http://chibios.sourceforge.net/
@ -74,11 +74,14 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
***************************************************************************** *****************************************************************************
*** 0.8.2 *** *** 0.8.2 ***
- FIX: Included the files that were missing from version 0.8.1 distribution.
- FIX: Duplicated sections in the documentation removed. - FIX: Duplicated sections in the documentation removed.
- FIX: Minor problem in Cortex-M3 and AVR ports when the kernel is compiled - FIX: Minor problem in Cortex-M3 and AVR ports when the kernel is compiled
using G++. using G++.
- NEW: Added chPoolAllocI() and chPoolFreeI() APIs in order to allow the use - NEW: Added chPoolAllocI() and chPoolFreeI() APIs in order to allow the use
of memory pools from interrupt handlers and timer callbacks. of memory pools from interrupt handlers and timer callbacks.
- CHANGE: Simplified the code for chThdWait(), it is now both smaller and
faster. Added an important usage note to the documentation of this API.
- CHANGE: The macros WorkingArea(), UserStackSize() and StackAlign() are now - CHANGE: The macros WorkingArea(), UserStackSize() and StackAlign() are now
deprecated and will be removed in version 1.0.0. Use the new equivalents deprecated and will be removed in version 1.0.0. Use the new equivalents
WORKING_AREA(), THD_WA_SIZE() and STACK_ALIGN() instead. WORKING_AREA(), THD_WA_SIZE() and STACK_ALIGN() instead.

View File

@ -40,7 +40,7 @@ Thread *init_thread(Thread *tp, tprio_t prio) {
tp->p_mtxlist = NULL; tp->p_mtxlist = NULL;
#endif #endif
#ifdef CH_USE_WAITEXIT #ifdef CH_USE_WAITEXIT
list_init(&tp->p_waiting); tp->p_waiting = NULL;
#endif #endif
#ifdef CH_USE_MESSAGES #ifdef CH_USE_MESSAGES
queue_init(&tp->p_msgqueue); queue_init(&tp->p_msgqueue);
@ -324,8 +324,10 @@ void chThdExit(msg_t msg) {
tp->p_exitcode = msg; tp->p_exitcode = msg;
THREAD_EXT_EXIT(tp); THREAD_EXT_EXIT(tp);
#ifdef CH_USE_WAITEXIT #ifdef CH_USE_WAITEXIT
while (notempty(&tp->p_waiting)) // while (notempty(&tp->p_waiting))
chSchReadyI(list_remove(&tp->p_waiting)); // chSchReadyI(list_remove(&tp->p_waiting));
if (tp->p_waiting != NULL)
chSchReadyI(tp->p_waiting);
#endif #endif
#ifdef CH_USE_EXIT_EVENT #ifdef CH_USE_EXIT_EVENT
chEvtBroadcastI(&tp->p_exitesource); chEvtBroadcastI(&tp->p_exitesource);
@ -354,14 +356,21 @@ void chThdExit(msg_t msg) {
* must not be used as parameter for further system calls. * must not be used as parameter for further system calls.
* @note The function is available only if the \p CH_USE_WAITEXIT * @note The function is available only if the \p CH_USE_WAITEXIT
* option is enabled in \p chconf.h. * option is enabled in \p chconf.h.
* @note Only one thread can be waiting for another thread at any time. You
* should imagine the threads as having a reference counter that is set
* to one when the thread is created, chThdWait() decreases the reference
* and the memory is freed when the counter reaches zero. In the current
* implementation there is no real reference counter in the thread
* structure but it is a planned extension.
*/ */
msg_t chThdWait(Thread *tp) { msg_t chThdWait(Thread *tp) {
msg_t msg; msg_t msg;
chSysLock(); chSysLock();
chDbgAssert((tp != NULL) && (tp != currp), "chthreads.c, chThdWait()"); chDbgAssert((tp != NULL) && (tp != currp) && (tp->p_waiting != NULL),
"chthreads.c, chThdWait()");
if (tp->p_state != PREXIT) { if (tp->p_state != PREXIT) {
list_insert(currp, &tp->p_waiting); tp->p_waiting = currp;
chSchGoSleepS(PRWAIT); chSchGoSleepS(PRWAIT);
} }
msg = tp->p_exitcode; msg = tp->p_exitcode;
@ -369,12 +378,8 @@ msg_t chThdWait(Thread *tp) {
chSysUnlock(); chSysUnlock();
return msg; return msg;
#else /* CH_USE_DYNAMIC */ #else /* CH_USE_DYNAMIC */
if (notempty(&tp->p_waiting)) {
chSysUnlock();
return msg;
}
/* This is the last thread waiting for termination, returning memory.*/ /* Returning memory.*/
tmode_t mode = tp->p_flags & P_MEM_MODE_MASK; tmode_t mode = tp->p_flags & P_MEM_MODE_MASK;
chSysUnlock(); chSysUnlock();

View File

@ -34,22 +34,22 @@
*/ */
struct Thread { struct Thread {
/** Next \p Thread in the threads list.*/ /** Next \p Thread in the threads list.*/
Thread *p_next; Thread *p_next;
/* End of the fields shared with the ThreadsList structure. */ /* End of the fields shared with the ThreadsList structure. */
/** Previous \p Thread in the threads list.*/ /** Previous \p Thread in the threads list.*/
Thread *p_prev; Thread *p_prev;
/* End of the fields shared with the ThreadsQueue structure. */ /* End of the fields shared with the ThreadsQueue structure. */
/** The thread priority.*/ /** The thread priority.*/
tprio_t p_prio; tprio_t p_prio;
/* End of the fields shared with the ReadyList structure. */ /* End of the fields shared with the ReadyList structure. */
/** Thread identifier. */ /** Thread identifier. */
tid_t p_tid; tid_t p_tid;
/** Current thread state.*/ /** Current thread state.*/
tstate_t p_state; tstate_t p_state;
/** Mode flags. */ /** Mode flags. */
tmode_t p_flags; tmode_t p_flags;
/** Machine dependent processor context.*/ /** Machine dependent processor context.*/
Context p_ctx; Context p_ctx;
/* /*
* The following fields are merged in unions because they are all * The following fields are merged in unions because they are all
* state-specific fields. This trick saves some extra space for each * state-specific fields. This trick saves some extra space for each
@ -57,34 +57,34 @@ struct Thread {
*/ */
union { union {
/** Thread wakeup code (only valid when exiting the \p PRREADY state).*/ /** Thread wakeup code (only valid when exiting the \p PRREADY state).*/
msg_t p_rdymsg; msg_t p_rdymsg;
/** The thread exit code (only while in \p PREXIT state).*/ /** The thread exit code (only while in \p PREXIT state).*/
msg_t p_exitcode; msg_t p_exitcode;
#ifdef CH_USE_SEMAPHORES #ifdef CH_USE_SEMAPHORES
/** Semaphore where the thread is waiting on (only in \p PRWTSEM state).*/ /** Semaphore where the thread is waiting on (only in \p PRWTSEM state).*/
Semaphore *p_wtsemp; Semaphore *p_wtsemp;
#endif #endif
#ifdef CH_USE_MUTEXES #ifdef CH_USE_MUTEXES
/** Mutex where the thread is waiting on (only in \p PRWTMTX state).*/ /** Mutex where the thread is waiting on (only in \p PRWTMTX state).*/
Mutex *p_wtmtxp; Mutex *p_wtmtxp;
#endif #endif
#ifdef CH_USE_CONDVARS #ifdef CH_USE_CONDVARS
/** CondVar where the thread is waiting on (only in \p PRWTCOND state).*/ /** CondVar where the thread is waiting on (only in \p PRWTCOND state).*/
CondVar *p_wtcondp; CondVar *p_wtcondp;
#endif #endif
#ifdef CH_USE_MESSAGES #ifdef CH_USE_MESSAGES
/** Destination thread for message send (only in \p PRSNDMSG state).*/ /** Destination thread for message send (only in \p PRSNDMSG state).*/
Thread *p_wtthdp; Thread *p_wtthdp;
#endif #endif
#ifdef CH_USE_EVENTS #ifdef CH_USE_EVENTS
/** Enabled events mask (only while in \p PRWTOREVT or \p PRWTANDEVT /** Enabled events mask (only while in \p PRWTOREVT or \p PRWTANDEVT
states). */ states). */
eventmask_t p_ewmask; eventmask_t p_ewmask;
#endif #endif
#ifdef CH_USE_TRACE #ifdef CH_USE_TRACE
/** Kernel object where the thread is waiting on. It is only valid when /** Kernel object where the thread is waiting on. It is only valid when
the thread is some sleeping states.*/ the thread is some sleeping states.*/
void *p_wtobjp; void *p_wtobjp;
#endif #endif
}; };
/* /*
@ -92,29 +92,29 @@ struct Thread {
*/ */
#ifdef CH_USE_WAITEXIT #ifdef CH_USE_WAITEXIT
/** The list of the threads waiting for this thread termination. */ /** The list of the threads waiting for this thread termination. */
ThreadsList p_waiting; Thread *p_waiting;
#endif #endif
#ifdef CH_USE_EXIT_EVENT #ifdef CH_USE_EXIT_EVENT
/** The thread termination \p EventSource. */ /** The thread termination \p EventSource. */
EventSource p_exitesource; EventSource p_exitesource;
#endif #endif
#ifdef CH_USE_MESSAGES #ifdef CH_USE_MESSAGES
ThreadsQueue p_msgqueue; ThreadsQueue p_msgqueue;
msg_t p_msg; msg_t p_msg;
#endif #endif
#ifdef CH_USE_EVENTS #ifdef CH_USE_EVENTS
/** Pending events mask. */ /** Pending events mask. */
eventmask_t p_epending; eventmask_t p_epending;
#endif #endif
#ifdef CH_USE_MUTEXES #ifdef CH_USE_MUTEXES
/** List of mutexes owned by this thread, \p NULL terminated. */ /** List of mutexes owned by this thread, \p NULL terminated. */
Mutex *p_mtxlist; Mutex *p_mtxlist;
/** Thread's own, non-inherited, priority. */ /** Thread's own, non-inherited, priority. */
tprio_t p_realprio; tprio_t p_realprio;
#endif #endif
#if defined(CH_USE_DYNAMIC) && defined(CH_USE_MEMPOOLS) #if defined(CH_USE_DYNAMIC) && defined(CH_USE_MEMPOOLS)
/** Memory Pool where the thread workspace is returned. */ /** Memory Pool where the thread workspace is returned. */
void *p_mpool; void *p_mpool;
#endif #endif
#ifdef CH_USE_THREAD_EXT #ifdef CH_USE_THREAD_EXT
THREAD_EXT_FIELDS THREAD_EXT_FIELDS