Committer:
PA
Date:
Thu Jun 21 14:04:44 2012 +0000
Revision:
0:7ae810ca8a42

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
PA 0:7ae810ca8a42 1 /* Copyright (c) 2012 mbed.org */
PA 0:7ae810ca8a42 2 #ifndef THREAD_H
PA 0:7ae810ca8a42 3 #define THREAD_H
PA 0:7ae810ca8a42 4
PA 0:7ae810ca8a42 5 #include <stdint.h>
PA 0:7ae810ca8a42 6 #include "cmsis_os.h"
PA 0:7ae810ca8a42 7
PA 0:7ae810ca8a42 8 namespace rtos {
PA 0:7ae810ca8a42 9
PA 0:7ae810ca8a42 10 /*! The Thread class allow defining, creating, and controlling thread functions in the system. */
PA 0:7ae810ca8a42 11 class Thread {
PA 0:7ae810ca8a42 12 public:
PA 0:7ae810ca8a42 13 /*! Create a new thread, and start it executing the specified function.
PA 0:7ae810ca8a42 14 \param task function to be executed by this thread.
PA 0:7ae810ca8a42 15 \param argument pointer that is passed to the thread function as start argument. (default: NULL).
PA 0:7ae810ca8a42 16 \param priority initial priority of the thread function. (default: osPriorityNormal).
PA 0:7ae810ca8a42 17 \param stacksz stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
PA 0:7ae810ca8a42 18 */
PA 0:7ae810ca8a42 19 Thread(void (*task)(void const *argument),
PA 0:7ae810ca8a42 20 void *argument=NULL,
PA 0:7ae810ca8a42 21 osPriority priority=osPriorityNormal,
PA 0:7ae810ca8a42 22 uint32_t stacksize=DEFAULT_STACK_SIZE);
PA 0:7ae810ca8a42 23
PA 0:7ae810ca8a42 24 /*! Terminate execution of a thread and remove it from Active Threads
PA 0:7ae810ca8a42 25 \return status code that indicates the execution status of the function.
PA 0:7ae810ca8a42 26 */
PA 0:7ae810ca8a42 27 osStatus terminate();
PA 0:7ae810ca8a42 28
PA 0:7ae810ca8a42 29 /*! Set priority of an active thread
PA 0:7ae810ca8a42 30 \param priority new priority value for the thread function.
PA 0:7ae810ca8a42 31 \return status code that indicates the execution status of the function.
PA 0:7ae810ca8a42 32 */
PA 0:7ae810ca8a42 33 osStatus set_priority(osPriority priority);
PA 0:7ae810ca8a42 34
PA 0:7ae810ca8a42 35 /*! Get priority of an active thread
PA 0:7ae810ca8a42 36 \ return current priority value of the thread function.
PA 0:7ae810ca8a42 37 */
PA 0:7ae810ca8a42 38 osPriority get_priority();
PA 0:7ae810ca8a42 39
PA 0:7ae810ca8a42 40 /*! Set the specified Signal Flags of an active thread.
PA 0:7ae810ca8a42 41 \param signals specifies the signal flags of the thread that should be set.
PA 0:7ae810ca8a42 42 \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
PA 0:7ae810ca8a42 43 */
PA 0:7ae810ca8a42 44 int32_t signal_set(int32_t signals);
PA 0:7ae810ca8a42 45
PA 0:7ae810ca8a42 46 /*! Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
PA 0:7ae810ca8a42 47 \param signals wait until all specified signal flags set or 0 for any single signal flag.
PA 0:7ae810ca8a42 48 \param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
PA 0:7ae810ca8a42 49 \return event flag information or error code.
PA 0:7ae810ca8a42 50 */
PA 0:7ae810ca8a42 51 static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever);
PA 0:7ae810ca8a42 52
PA 0:7ae810ca8a42 53
PA 0:7ae810ca8a42 54 /*! Wait for a specified time period in millisec:
PA 0:7ae810ca8a42 55 \param millisec time delay value
PA 0:7ae810ca8a42 56 \return status code that indicates the execution status of the function.
PA 0:7ae810ca8a42 57 */
PA 0:7ae810ca8a42 58 static osStatus wait(uint32_t millisec);
PA 0:7ae810ca8a42 59
PA 0:7ae810ca8a42 60 /*! Pass control to next thread that is in state READY.
PA 0:7ae810ca8a42 61 \return status code that indicates the execution status of the function.
PA 0:7ae810ca8a42 62 */
PA 0:7ae810ca8a42 63 static osStatus yield();
PA 0:7ae810ca8a42 64
PA 0:7ae810ca8a42 65 /*! Get the thread id of the current running thread.
PA 0:7ae810ca8a42 66 \return thread ID for reference by other functions or NULL in case of error.
PA 0:7ae810ca8a42 67 */
PA 0:7ae810ca8a42 68 static osThreadId gettid();
PA 0:7ae810ca8a42 69
PA 0:7ae810ca8a42 70 private:
PA 0:7ae810ca8a42 71 osThreadId _tid;
PA 0:7ae810ca8a42 72 osThreadDef_t _thread_def;
PA 0:7ae810ca8a42 73 };
PA 0:7ae810ca8a42 74
PA 0:7ae810ca8a42 75 }
PA 0:7ae810ca8a42 76 #endif