aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-12-06 10:59:44 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-12-06 10:59:44 +0000
commitd8b450d8a085817ad26528cb58059da22ebea462 (patch)
tree1b79897787b256cdbecc7ea60417b3114f81a3db
parent87befad2540f95a8c38592981b7702a6fee06052 (diff)
downloadChibiOS-d8b450d8a085817ad26528cb58059da22ebea462.tar.gz
ChibiOS-d8b450d8a085817ad26528cb58059da22ebea462.tar.bz2
ChibiOS-d8b450d8a085817ad26528cb58059da22ebea462.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@529 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--docs/reports/MSP430F1611-0.75.txt8
-rw-r--r--readme.txt5
-rw-r--r--src/chthreads.c25
-rw-r--r--src/include/threads.h46
4 files changed, 47 insertions, 37 deletions
diff --git a/docs/reports/MSP430F1611-0.75.txt b/docs/reports/MSP430F1611-0.75.txt
index 7e6e39ee8..b71c5a37b 100644
--- a/docs/reports/MSP430F1611-0.75.txt
+++ b/docs/reports/MSP430F1611-0.75.txt
@@ -1,5 +1,5 @@
***************************************************************************
-Kernel: ChibiOS/RT 0.8.0
+Kernel: ChibiOS/RT 0.8.2
Compiler: GCC 3.2.3 (MSPGCC)
Options: -O2 -fomit-frame-pointer
Settings: MCLK=DCOCLK 750Khz
@@ -65,11 +65,11 @@ Settings: MCLK=DCOCLK 750Khz
--- Result: SUCCESS
---------------------------------------------------------------------------
--- Test Case 19 (Benchmark, threads creation/termination, worst case)
---- Score : 1166 threads/S
+--- Score : 1236 threads/S
--- Result: SUCCESS
---------------------------------------------------------------------------
--- Test Case 20 (Benchmark, threads creation/termination, optimal)
---- Score : 1537 threads/S
+--- Score : 1560 threads/S
--- Result: SUCCESS
---------------------------------------------------------------------------
--- Test Case 21 (Benchmark, mass reschedulation, 5 threads)
@@ -84,3 +84,5 @@ Settings: MCLK=DCOCLK 750Khz
--- Score : 5632 timers/S
--- Result: SUCCESS
---------------------------------------------------------------------------
+
+Final result: SUCCESS
diff --git a/readme.txt b/readme.txt
index 17615ffc2..c5a79c7be 100644
--- a/readme.txt
+++ b/readme.txt
@@ -18,7 +18,7 @@
./ext/ - External libraries or other code not part of
ChibiOS/RT but used in the demo applications.
./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).
The documentation is also available on the project
web page: http://chibios.sourceforge.net/
@@ -74,11 +74,14 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
*****************************************************************************
*** 0.8.2 ***
+- FIX: Included the files that were missing from version 0.8.1 distribution.
- FIX: Duplicated sections in the documentation removed.
- FIX: Minor problem in Cortex-M3 and AVR ports when the kernel is compiled
using G++.
- NEW: Added chPoolAllocI() and chPoolFreeI() APIs in order to allow the use
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
deprecated and will be removed in version 1.0.0. Use the new equivalents
WORKING_AREA(), THD_WA_SIZE() and STACK_ALIGN() instead.
diff --git a/src/chthreads.c b/src/chthreads.c
index 394da5d2a..6b1121d97 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -40,7 +40,7 @@ Thread *init_thread(Thread *tp, tprio_t prio) {
tp->p_mtxlist = NULL;
#endif
#ifdef CH_USE_WAITEXIT
- list_init(&tp->p_waiting);
+ tp->p_waiting = NULL;
#endif
#ifdef CH_USE_MESSAGES
queue_init(&tp->p_msgqueue);
@@ -324,8 +324,10 @@ void chThdExit(msg_t msg) {
tp->p_exitcode = msg;
THREAD_EXT_EXIT(tp);
#ifdef CH_USE_WAITEXIT
- while (notempty(&tp->p_waiting))
- chSchReadyI(list_remove(&tp->p_waiting));
+// while (notempty(&tp->p_waiting))
+// chSchReadyI(list_remove(&tp->p_waiting));
+ if (tp->p_waiting != NULL)
+ chSchReadyI(tp->p_waiting);
#endif
#ifdef CH_USE_EXIT_EVENT
chEvtBroadcastI(&tp->p_exitesource);
@@ -354,14 +356,21 @@ void chThdExit(msg_t msg) {
* 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.
+ * @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 msg;
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) {
- list_insert(currp, &tp->p_waiting);
+ tp->p_waiting = currp;
chSchGoSleepS(PRWAIT);
}
msg = tp->p_exitcode;
@@ -369,12 +378,8 @@ msg_t chThdWait(Thread *tp) {
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.*/
+ /* Returning memory.*/
tmode_t mode = tp->p_flags & P_MEM_MODE_MASK;
chSysUnlock();
diff --git a/src/include/threads.h b/src/include/threads.h
index d5f82ea9f..959a48b0e 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -34,22 +34,22 @@
*/
struct Thread {
/** Next \p Thread in the threads list.*/
- Thread *p_next;
+ Thread *p_next;
/* End of the fields shared with the ThreadsList structure. */
/** Previous \p Thread in the threads list.*/
- Thread *p_prev;
+ Thread *p_prev;
/* End of the fields shared with the ThreadsQueue structure. */
/** The thread priority.*/
- tprio_t p_prio;
+ tprio_t p_prio;
/* End of the fields shared with the ReadyList structure. */
/** Thread identifier. */
- tid_t p_tid;
+ tid_t p_tid;
/** Current thread state.*/
- tstate_t p_state;
+ tstate_t p_state;
/** Mode flags. */
- tmode_t p_flags;
+ tmode_t p_flags;
/** Machine dependent processor context.*/
- Context p_ctx;
+ Context p_ctx;
/*
* The following fields are merged in unions because they are all
* state-specific fields. This trick saves some extra space for each
@@ -57,34 +57,34 @@ struct Thread {
*/
union {
/** 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).*/
- msg_t p_exitcode;
+ msg_t p_exitcode;
#ifdef CH_USE_SEMAPHORES
/** Semaphore where the thread is waiting on (only in \p PRWTSEM state).*/
- Semaphore *p_wtsemp;
+ Semaphore *p_wtsemp;
#endif
#ifdef CH_USE_MUTEXES
/** Mutex where the thread is waiting on (only in \p PRWTMTX state).*/
- Mutex *p_wtmtxp;
+ Mutex *p_wtmtxp;
#endif
#ifdef CH_USE_CONDVARS
/** CondVar where the thread is waiting on (only in \p PRWTCOND state).*/
- CondVar *p_wtcondp;
+ CondVar *p_wtcondp;
#endif
#ifdef CH_USE_MESSAGES
/** Destination thread for message send (only in \p PRSNDMSG state).*/
- Thread *p_wtthdp;
+ Thread *p_wtthdp;
#endif
#ifdef CH_USE_EVENTS
/** Enabled events mask (only while in \p PRWTOREVT or \p PRWTANDEVT
states). */
- eventmask_t p_ewmask;
+ eventmask_t p_ewmask;
#endif
#ifdef CH_USE_TRACE
/** Kernel object where the thread is waiting on. It is only valid when
the thread is some sleeping states.*/
- void *p_wtobjp;
+ void *p_wtobjp;
#endif
};
/*
@@ -92,29 +92,29 @@ struct Thread {
*/
#ifdef CH_USE_WAITEXIT
/** The list of the threads waiting for this thread termination. */
- ThreadsList p_waiting;
+ Thread *p_waiting;
#endif
#ifdef CH_USE_EXIT_EVENT
/** The thread termination \p EventSource. */
- EventSource p_exitesource;
+ EventSource p_exitesource;
#endif
#ifdef CH_USE_MESSAGES
- ThreadsQueue p_msgqueue;
- msg_t p_msg;
+ ThreadsQueue p_msgqueue;
+ msg_t p_msg;
#endif
#ifdef CH_USE_EVENTS
/** Pending events mask. */
- eventmask_t p_epending;
+ eventmask_t p_epending;
#endif
#ifdef CH_USE_MUTEXES
/** List of mutexes owned by this thread, \p NULL terminated. */
- Mutex *p_mtxlist;
+ Mutex *p_mtxlist;
/** Thread's own, non-inherited, priority. */
- tprio_t p_realprio;
+ 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;
+ void *p_mpool;
#endif
#ifdef CH_USE_THREAD_EXT
THREAD_EXT_FIELDS