diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-03-17 13:04:42 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-03-17 13:04:42 +0000 |
commit | 392c2fe70d224c4f564ebab5dcd3f0d607a546f0 (patch) | |
tree | b6a0e86bef6c21dd755bf18d32cf18d93856d14b /os | |
parent | ad3d21e81592481539a56e93234f5bf1fa2c0504 (diff) | |
download | ChibiOS-392c2fe70d224c4f564ebab5dcd3f0d607a546f0.tar.gz ChibiOS-392c2fe70d224c4f564ebab5dcd3f0d607a546f0.tar.bz2 ChibiOS-392c2fe70d224c4f564ebab5dcd3f0d607a546f0.zip |
Fixed bug 2971878 .
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1747 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/kernel/src/chregistry.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/os/kernel/src/chregistry.c b/os/kernel/src/chregistry.c index 4dca52534..5ed8ace2e 100644 --- a/os/kernel/src/chregistry.c +++ b/os/kernel/src/chregistry.c @@ -23,6 +23,16 @@ *
* @addtogroup registry
* @details Threads Registry related APIs and services.<br>
+ * The threads Threads Registry is a double linked list that holds
+ * all the active threads in the system.<br>
+ * The registry is meant to be mainly a debug feature, as example
+ * through the registry a debugger can enumerate the active threads
+ * in any given moment or the shell can print the active threads and
+ * their state.<br>
+ * Another possible use is for centralized threads memory management,
+ * terminating threads can pulse an event source and an event handler
+ * can perform a scansion of the registry in order to recover the
+ * memory.<br>
* In order to use the threads registry the @p CH_USE_REGISTRY option
* must be enabled in @p chconf.h.
* @{
@@ -64,25 +74,24 @@ Thread *chRegFirstThread(void) { * @retval NULL if there is no next thread.
*/
Thread *chRegNextThread(Thread *tp) {
+ Thread *ntp;
chSysLock();
+ ntp = tp->p_newer;
+ if (ntp == (Thread *)&rlist)
+ ntp = NULL;
#if CH_USE_DYNAMIC
- chDbgAssert(tp->p_refs > 0, "chRegNextThread(), #1",
- "not referenced");
- tp->p_refs--;
-#endif
- if (tp->p_newer != (Thread *)&rlist) {
- tp = tp->p_newer;
-#if CH_USE_DYNAMIC
- chDbgAssert(tp->p_refs < 255, "chRegNextThread(), #2",
+ else {
+ chDbgAssert(ntp->p_refs < 255, "chRegNextThread(), #1",
"too many references");
- tp->p_refs++;
-#endif
+ ntp->p_refs++;
}
- else
- tp = NULL;
+#endif
chSysUnlock();
- return tp;
+#if CH_USE_DYNAMIC
+ chThdRelease(tp);
+#endif
+ return ntp;
}
#endif /* CH_USE_REGISTRY */
|