From 66ff6722d223a1fee94c13f2704dda48acc63e8e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 6 Oct 2014 14:31:11 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7380 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/ports/ARMCMx/cmsis_os/cmsis_os.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'os/rt/ports/ARMCMx/cmsis_os/cmsis_os.c') 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 @@ -108,6 +108,39 @@ osStatus osKernelStart(void) { return osOK; } +/** + * @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. -- cgit v1.2.3