aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-02-25 10:37:07 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-02-25 10:37:07 +0000
commitfde2a2cc60934f77816a4d2200b97127cdb3a6d2 (patch)
tree6afa1382dce1df73e3cdcfef7cb2513bf926532e /os/rt
parentfcb8c906094c82bbdba975ee7370f47d9a7b3e24 (diff)
downloadChibiOS-fde2a2cc60934f77816a4d2200b97127cdb3a6d2.tar.gz
ChibiOS-fde2a2cc60934f77816a4d2200b97127cdb3a6d2.tar.bz2
ChibiOS-fde2a2cc60934f77816a4d2200b97127cdb3a6d2.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8946 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt')
-rw-r--r--os/rt/include/chregistry.h1
-rw-r--r--os/rt/src/chregistry.c27
2 files changed, 28 insertions, 0 deletions
diff --git a/os/rt/include/chregistry.h b/os/rt/include/chregistry.h
index a786e93a0..f60b1b2c3 100644
--- a/os/rt/include/chregistry.h
+++ b/os/rt/include/chregistry.h
@@ -110,6 +110,7 @@ extern "C" {
thread_t *chRegNextThread(thread_t *tp);
thread_t *chRegFindThreadByName(const char *name);
thread_t *chRegFindThreadByPointer(thread_t *tp);
+ thread_t *chRegFindThreadByWorkingArea(stkalign_t *wa);
#ifdef __cplusplus
}
#endif
diff --git a/os/rt/src/chregistry.c b/os/rt/src/chregistry.c
index ec90b4168..24246c012 100644
--- a/os/rt/src/chregistry.c
+++ b/os/rt/src/chregistry.c
@@ -233,6 +233,33 @@ thread_t *chRegFindThreadByPointer(thread_t *tp) {
return NULL;
}
+/**
+ * @brief Confirms that a working area is being used by some active thread.
+ * @note The reference counter of the found thread is increased by one so
+ * it cannot be disposed incidentally after the pointer has been
+ * returned.
+ *
+ * @param[in] wa pointer to a static working area
+ * @return A pointer to the found thread.
+ * @retval NULL if a matching thread has not been found.
+ *
+ * @api
+ */
+thread_t *chRegFindThreadByWorkingArea(stkalign_t *wa) {
+ thread_t *ctp;
+
+ /* Scanning registry.*/
+ ctp = chRegFirstThread();
+ do {
+ if (ctp->stklimit == wa) {
+ return ctp;
+ }
+ ctp = chRegNextThread(ctp);
+ } while (ctp != NULL);
+
+ return NULL;
+}
+
#endif /* CH_CFG_USE_REGISTRY == TRUE */
/** @} */