aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-10-06 14:31:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-10-06 14:31:11 +0000
commit66ff6722d223a1fee94c13f2704dda48acc63e8e (patch)
tree6881daf68b7c49eee49c1a2a7e8b879e7d95d84f /os
parent855065f2390b698ef6e1e68a7a75535230b3e1e8 (diff)
downloadChibiOS-66ff6722d223a1fee94c13f2704dda48acc63e8e.tar.gz
ChibiOS-66ff6722d223a1fee94c13f2704dda48acc63e8e.tar.bz2
ChibiOS-66ff6722d223a1fee94c13f2704dda48acc63e8e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7380 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/rt/ports/ARMCMx/cmsis_os/cmsis_os.c33
-rw-r--r--os/rt/ports/ARMCMx/cmsis_os/cmsis_os.h34
2 files changed, 42 insertions, 25 deletions
diff --git a/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.c b/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.c
index d8aa35cb5..9cf601248 100644
--- a/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.c
+++ b/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.c
@@ -109,6 +109,39 @@ osStatus osKernelStart(void) {
}
/**
+ * @brief Creates a thread.
+ */
+osThreadId osThreadCreate (osThreadDef_t *thread_def, void *argument) {
+ size_t size;
+
+ size = thread_def->stacksize == 0 ? CMSIS_CFG_DEFAULT_STACK :
+ thread_def->stacksize;
+ return (osThreadId)chThdCreateFromHeap(0,
+ THD_WORKING_AREA_SIZE(size),
+ NORMALPRIO+thread_def->tpriority,
+ (tfunc_t)thread_def->pthread,
+ argument);
+}
+
+/**
+ * @brief Thread termination.
+ * @note The thread is not really terminated but asked to terminate which
+ * is not compliant.
+ */
+osStatus osThreadTerminate(osThreadId thread_id) {
+
+ if (thread_id == osThreadGetId()) {
+ /* Note, no memory will be recovered unless a cleaner thread is
+ implemented using the registry.*/
+ chThdExit(0);
+ }
+ chThdTerminate(thread_id);
+ chThdWait((thread_t *)thread_id);
+
+ return osOK;
+}
+
+/**
* @brief Change thread priority.
* @note This can interfere with the priority inheritance mechanism.
*/
diff --git a/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.h b/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.h
index 3151a8f39..6de5830dd 100644
--- a/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.h
+++ b/os/rt/ports/ARMCMx/cmsis_os/cmsis_os.h
@@ -86,6 +86,13 @@
/**
* @brief Number of pre-allocated static semaphores/mutexes.
*/
+#if !defined(CMSIS_CFG_DEFAULT_STACK)
+#define CMSIS_CFG_DEFAULT_STACK 256
+#endif
+
+/**
+ * @brief Number of pre-allocated static semaphores/mutexes.
+ */
#if !defined(CMSIS_CFG_NUM_SEMAPHORES)
#define CMSIS_CFG_NUM_SEMAPHORES 4
#endif
@@ -340,6 +347,8 @@ extern "C" {
#endif
osStatus osKernelInitialize(void);
osStatus osKernelStart(void);
+ osThreadId osThreadCreate (osThreadDef_t *thread_def, void *argument);
+ osStatus osThreadTerminate (osThreadId thread_id);
osStatus osThreadSetPriority(osThreadId thread_id, osPriority newprio);
/*osEvent osWait(uint32_t millisec);*/
osTimerId osTimerCreate (const osTimerDef_t *timer_def,
@@ -385,19 +394,6 @@ static inline uint32_t osKernelSysTick(void) {
}
/**
- * @brief Creates a thread.
- */
-static inline osThreadId osThreadCreate (osThreadDef_t *thread_def,
- void *argument) {
-
- return (osThreadId)chThdCreateFromHeap(0,
- THD_WORKING_AREA_SIZE(thread_def->stacksize),
- NORMALPRIO+thread_def->tpriority,
- (tfunc_t)thread_def->pthread,
- argument);
-}
-
-/**
* @brief Returns the current thread.
*/
static inline osThreadId osThreadGetId(void) {
@@ -406,18 +402,6 @@ static inline osThreadId osThreadGetId(void) {
}
/**
- * @brief Thread termination.
- * @note The thread is not really terminated but asked to terminate which
- * is not compliant.
- */
-static inline osStatus osThreadTerminate(osThreadId thread_id) {
-
- chThdTerminate(thread_id);
-
- return osOK;
-}
-
-/**
* @brief Thread time slice yield.
*/
static inline osStatus osThreadYield(void) {