Mistake on this page?
Report an issue in GitHub or email us
Thread.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2012 ARM Limited
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 #ifndef THREAD_H
23 #define THREAD_H
24 
25 #include <stdint.h>
26 #include "cmsis_os2.h"
27 #include "mbed_rtos1_types.h"
28 #include "mbed_rtos_storage.h"
29 #include "platform/Callback.h"
30 #include "platform/mbed_toolchain.h"
31 #include "platform/NonCopyable.h"
32 #include "rtos/Semaphore.h"
33 #include "rtos/Mutex.h"
34 
35 namespace rtos {
36 /** \addtogroup rtos */
37 /** @{*/
38 /**
39  * \defgroup rtos_Thread Thread class
40  * @{
41  */
42 
43 /** The Thread class allow defining, creating, and controlling thread functions in the system.
44  *
45  * Example:
46  * @code
47  * #include "mbed.h"
48  * #include "rtos.h"
49  *
50  * Thread thread;
51  * DigitalOut led1(LED1);
52  * volatile bool running = true;
53  *
54  * // Blink function toggles the led in a long running loop
55  * void blink(DigitalOut *led) {
56  * while (running) {
57  * *led = !*led;
58  * wait(1);
59  * }
60  * }
61  *
62  * // Spawns a thread to run blink for 5 seconds
63  * int main() {
64  * thread.start(callback(blink, &led1));
65  * wait(5);
66  * running = false;
67  * thread.join();
68  * }
69  * @endcode
70  *
71  * @note
72  * Memory considerations: The thread control structures will be created on current thread's stack, both for the mbed OS
73  * and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
74  * Additionally the stack memory for this thread will be allocated on the heap, if it wasn't supplied to the constructor.
75  *
76  * @note
77  * MBED_TZ_DEFAULT_ACCESS (default:0) flag can be used to change the default access of all user threads in non-secure mode.
78  * MBED_TZ_DEFAULT_ACCESS set to 1, means all non-secure user threads have access to call secure functions.
79  * MBED_TZ_DEFAULT_ACCESS set to 0, means none of the non-secure user thread have access to call secure functions,
80  * to give access to particular thread used overloaded constructor with `tz_module` as argument during thread creation.
81  *
82  * MBED_TZ_DEFAULT_ACCESS is target specific define, should be set in targets.json file for Cortex-M23/M33 devices.
83  */
84 
85 class Thread : private mbed::NonCopyable<Thread> {
86 public:
87  /** Allocate a new thread without starting execution
88  @param priority initial priority of the thread function. (default: osPriorityNormal).
89  @param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
90  @param stack_mem pointer to the stack area to be used by this thread (default: NULL).
91  @param name name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: NULL)
92 
93  @note Default value of tz_module will be MBED_TZ_DEFAULT_ACCESS
94  @note You cannot call this function from ISR context.
95  */
96 
97  Thread(osPriority priority = osPriorityNormal,
98  uint32_t stack_size = OS_STACK_SIZE,
99  unsigned char *stack_mem = NULL, const char *name = NULL)
100  {
101  constructor(priority, stack_size, stack_mem, name);
102  }
103 
104  /** Allocate a new thread without starting execution
105  @param tz_module trustzone thread identifier (osThreadAttr_t::tz_module)
106  Context of RTOS threads in non-secure state must be saved when calling secure functions.
107  tz_module ID is used to allocate context memory for threads, and it can be safely set to zero for
108  threads not using secure calls at all. See "TrustZone RTOS Context Management" for more details.
109  @param priority initial priority of the thread function. (default: osPriorityNormal).
110  @param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
111  @param stack_mem pointer to the stack area to be used by this thread (default: NULL).
112  @param name name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: NULL)
113 
114  @note You cannot call this function from ISR context.
115  */
116 
117  Thread(uint32_t tz_module, osPriority priority = osPriorityNormal,
118  uint32_t stack_size = OS_STACK_SIZE,
119  unsigned char *stack_mem = NULL, const char *name = NULL)
120  {
121  constructor(tz_module, priority, stack_size, stack_mem, name);
122  }
123 
124 
125  /** Create a new thread, and start it executing the specified function.
126  @param task function to be executed by this thread.
127  @param priority initial priority of the thread function. (default: osPriorityNormal).
128  @param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
129  @param stack_mem pointer to the stack area to be used by this thread (default: NULL).
130  @deprecated
131  Thread-spawning constructors hide errors. Replaced by thread.start(task).
132 
133  @code
134  Thread thread(priority, stack_size, stack_mem);
135 
136  osStatus status = thread.start(task);
137  if (status != osOK) {
138  error("oh no!");
139  }
140  @endcode
141 
142  @note You cannot call this function from ISR context.
143  */
144  MBED_DEPRECATED_SINCE("mbed-os-5.1",
145  "Thread-spawning constructors hide errors. "
146  "Replaced by thread.start(task).")
147  Thread(mbed::Callback<void()> task,
148  osPriority priority = osPriorityNormal,
149  uint32_t stack_size = OS_STACK_SIZE,
150  unsigned char *stack_mem = NULL)
151  {
152  constructor(task, priority, stack_size, stack_mem);
153  }
154 
155  /** Create a new thread, and start it executing the specified function.
156  @param argument pointer that is passed to the thread function as start argument. (default: NULL).
157  @param task argument to task.
158  @param priority initial priority of the thread function. (default: osPriorityNormal).
159  @param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
160  @param stack_mem pointer to the stack area to be used by this thread (default: NULL).
161  @deprecated
162  Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
163 
164  @code
165  Thread thread(priority, stack_size, stack_mem);
166 
167  osStatus status = thread.start(callback(task, argument));
168  if (status != osOK) {
169  error("oh no!");
170  }
171  @endcode
172 
173  @note You cannot call this function from ISR context.
174  */
175  template <typename T>
176  MBED_DEPRECATED_SINCE("mbed-os-5.1",
177  "Thread-spawning constructors hide errors. "
178  "Replaced by thread.start(callback(task, argument)).")
179  Thread(T *argument, void (T::*task)(),
180  osPriority priority = osPriorityNormal,
181  uint32_t stack_size = OS_STACK_SIZE,
182  unsigned char *stack_mem = NULL)
183  {
184  constructor(mbed::callback(task, argument),
185  priority, stack_size, stack_mem);
186  }
187 
188  /** Create a new thread, and start it executing the specified function.
189  @param argument pointer that is passed to the thread function as start argument. (default: NULL).
190  @param task argument to task.
191  @param priority initial priority of the thread function. (default: osPriorityNormal).
192  @param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
193  @param stack_mem pointer to the stack area to be used by this thread (default: NULL).
194  @deprecated
195  Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
196 
197  @code
198  Thread thread(priority, stack_size, stack_mem);
199 
200  osStatus status = thread.start(callback(task, argument));
201  if (status != osOK) {
202  error("oh no!");
203  }
204  @endcode
205 
206  @note You cannot call this function from ISR context.
207  */
208  template <typename T>
209  MBED_DEPRECATED_SINCE("mbed-os-5.1",
210  "Thread-spawning constructors hide errors. "
211  "Replaced by thread.start(callback(task, argument)).")
212  Thread(T *argument, void (*task)(T *),
213  osPriority priority = osPriorityNormal,
214  uint32_t stack_size = OS_STACK_SIZE,
215  unsigned char *stack_mem = NULL)
216  {
217  constructor(mbed::callback(task, argument),
218  priority, stack_size, stack_mem);
219  }
220 
221  /** Create a new thread, and start it executing the specified function.
222  Provided for backwards compatibility
223  @param task function to be executed by this thread.
224  @param argument pointer that is passed to the thread function as start argument. (default: NULL).
225  @param priority initial priority of the thread function. (default: osPriorityNormal).
226  @param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
227  @param stack_mem pointer to the stack area to be used by this thread (default: NULL).
228  @deprecated
229  Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
230 
231  @code
232  Thread thread(priority, stack_size, stack_mem);
233 
234  osStatus status = thread.start(callback(task, argument));
235  if (status != osOK) {
236  error("oh no!");
237  }
238  @endcode
239 
240  @note You cannot call this function from ISR context.
241  */
242  MBED_DEPRECATED_SINCE("mbed-os-5.1",
243  "Thread-spawning constructors hide errors. "
244  "Replaced by thread.start(callback(task, argument)).")
245  Thread(void (*task)(void const *argument), void *argument = NULL,
246  osPriority priority = osPriorityNormal,
247  uint32_t stack_size = OS_STACK_SIZE,
248  unsigned char *stack_mem = NULL)
249  {
250  constructor(mbed::callback((void (*)(void *))task, argument),
251  priority, stack_size, stack_mem);
252  }
253 
254  /** Starts a thread executing the specified function.
255  @param task function to be executed by this thread.
256  @return status code that indicates the execution status of the function.
257  @note a thread can only be started once
258 
259  @note You cannot call this function ISR context.
260  */
261  osStatus start(mbed::Callback<void()> task);
262 
263  /** Starts a thread executing the specified function.
264  @param obj argument to task
265  @param method function to be executed by this thread.
266  @return status code that indicates the execution status of the function.
267  @deprecated
268  The start function does not support cv-qualifiers. Replaced by start(callback(obj, method)).
269 
270  @note You cannot call this function from ISR context.
271  */
272  template <typename T, typename M>
273  MBED_DEPRECATED_SINCE("mbed-os-5.1",
274  "The start function does not support cv-qualifiers. "
275  "Replaced by thread.start(callback(obj, method)).")
276  osStatus start(T *obj, M method)
277  {
278  return start(mbed::callback(obj, method));
279  }
280 
281  /** Wait for thread to terminate
282  @return status code that indicates the execution status of the function.
283 
284  @note You cannot call this function from ISR context.
285  */
286  osStatus join();
287 
288  /** Terminate execution of a thread and remove it from Active Threads
289  @return status code that indicates the execution status of the function.
290 
291  @note You cannot call this function from ISR context.
292  */
293  osStatus terminate();
294 
295  /** Set priority of an active thread
296  @param priority new priority value for the thread function.
297  @return status code that indicates the execution status of the function.
298 
299  @note You cannot call this function from ISR context.
300  */
301  osStatus set_priority(osPriority priority);
302 
303  /** Get priority of an active thread
304  @return current priority value of the thread function.
305 
306  @note You cannot call this function from ISR context.
307  */
308  osPriority get_priority() const;
309 
310  /** Set the specified Thread Flags for the thread.
311  @param flags specifies the flags of the thread that should be set.
312  @return thread flags after setting or osFlagsError in case of incorrect parameters.
313 
314  @note You may call this function from ISR context.
315  */
316  uint32_t flags_set(uint32_t flags);
317 
318  /** Set the specified Thread Flags for the thread.
319  @param signals specifies the signal flags of the thread that should be set.
320  @return signal flags after setting or osFlagsError in case of incorrect parameters.
321 
322  @note You may call this function from ISR context.
323  @deprecated Other signal_xxx methods have been deprecated in favour of ThisThread::flags functions.
324  To match this naming scheme, derived from CMSIS-RTOS2, Thread::flags_set is now provided.
325  */
326  MBED_DEPRECATED_SINCE("mbed-os-5.10",
327  "Other signal_xxx methods have been deprecated in favour of ThisThread::flags functions. "
328  "To match this naming scheme, derived from CMSIS-RTOS2, Thread::flags_set is now provided.")
329  int32_t signal_set(int32_t signals);
330 
331  /** State of the Thread */
332  enum State {
333  Inactive, /**< NOT USED */
334  Ready, /**< Ready to run */
335  Running, /**< Running */
336  WaitingDelay, /**< Waiting for a delay to occur */
337  WaitingJoin, /**< Waiting for thread to join. Only happens when using RTX directly. */
338  WaitingThreadFlag, /**< Waiting for a thread flag to be set */
339  WaitingEventFlag, /**< Waiting for a event flag to be set */
340  WaitingMutex, /**< Waiting for a mutex event to occur */
341  WaitingSemaphore, /**< Waiting for a semaphore event to occur */
342  WaitingMemoryPool, /**< Waiting for a memory pool */
343  WaitingMessageGet, /**< Waiting for message to arrive */
344  WaitingMessagePut, /**< Waiting for message to be send */
345  WaitingInterval, /**< NOT USED */
346  WaitingOr, /**< NOT USED */
347  WaitingAnd, /**< NOT USED */
348  WaitingMailbox, /**< NOT USED (Mail is implemented as MemoryPool and Queue) */
349 
350  /* Not in sync with RTX below here */
351  Deleted, /**< The task has been deleted or not started */
352  };
353 
354  /** State of this Thread
355  @return the State of this Thread
356 
357  @note You cannot call this function from ISR context.
358  */
359  State get_state() const;
360 
361  /** Get the total stack memory size for this Thread
362  @return the total stack memory size in bytes
363 
364  @note You cannot call this function from ISR context.
365  */
366  uint32_t stack_size() const;
367 
368  /** Get the currently unused stack memory for this Thread
369  @return the currently unused stack memory in bytes
370 
371  @note You cannot call this function from ISR context.
372  */
373  uint32_t free_stack() const;
374 
375  /** Get the currently used stack memory for this Thread
376  @return the currently used stack memory in bytes
377 
378  @note You cannot call this function from ISR context.
379  */
380  uint32_t used_stack() const;
381 
382  /** Get the maximum stack memory usage to date for this Thread
383  @return the maximum stack memory usage to date in bytes
384 
385  @note You cannot call this function from ISR context.
386  */
387  uint32_t max_stack() const;
388 
389  /** Get thread name
390  @return thread name or NULL if the name was not set.
391 
392  @note You may call this function from ISR context.
393  */
394  const char *get_name() const;
395 
396  /** Get thread id
397  @return thread ID for reference by other functions.
398 
399  @note You may call this function from ISR context.
400  */
401  osThreadId_t get_id() const;
402 
403  /** Clears the specified Thread Flags of the currently running thread.
404  @param signals specifies the signal flags of the thread that should be cleared.
405  @return signal flags before clearing or osFlagsError in case of incorrect parameters.
406 
407  @note You cannot call this function from ISR context.
408  @deprecated Static methods only affecting current thread cause confusion. Replaced by ThisThread::flags_clear.
409  */
410  MBED_DEPRECATED_SINCE("mbed-os-5.10",
411  "Static methods only affecting current thread cause confusion. "
412  "Replaced by ThisThread::flags_clear.")
413  static int32_t signal_clr(int32_t signals);
414 
415  /** Wait for one or more Thread Flags to become signaled for the current RUNNING thread.
416  @param signals wait until all specified signal flags are set or 0 for any single signal flag.
417  @param millisec timeout value. (default: osWaitForever).
418  @return event flag information or error code. @note if @a millisec is set to 0 and flag is no set the event carries osOK value.
419 
420  @note You cannot call this function from ISR context.
421  @deprecated Static methods only affecting current thread cause confusion.
422  Replaced by ThisThread::flags_wait_all, ThisThread::flags_wait_all_for, ThisThread::flags_wait_any and ThisThread:wait_any_for.
423  */
424  MBED_DEPRECATED_SINCE("mbed-os-5.10",
425  "Static methods only affecting current thread cause confusion. "
426  "Replaced by ThisThread::flags_wait_all, ThisThread::flags_wait_all_for, ThisThread::flags_wait_any and ThisThread:wait_any_for.")
427  static osEvent signal_wait(int32_t signals, uint32_t millisec = osWaitForever);
428 
429  /** Wait for a specified time period in milliseconds
430  Being tick-based, the delay will be up to the specified time - eg for
431  a value of 1 the system waits until the next millisecond tick occurs,
432  leading to a delay of 0-1 milliseconds.
433  @param millisec time delay value
434  @return status code that indicates the execution status of the function.
435 
436  @note You cannot call this function from ISR context.
437  @deprecated Static methods only affecting current thread cause confusion. Replaced by ThisThread::sleep_for.
438  */
439  MBED_DEPRECATED_SINCE("mbed-os-5.10",
440  "Static methods only affecting current thread cause confusion. "
441  "Replaced by ThisThread::sleep_for.")
442  static osStatus wait(uint32_t millisec);
443 
444  /** Wait until a specified time in millisec
445  The specified time is according to Kernel::get_ms_count().
446  @param millisec absolute time in millisec
447  @return status code that indicates the execution status of the function.
448  @note not callable from interrupt
449  @note if millisec is equal to or lower than the current tick count, this
450  returns immediately, either with an error or "osOK".
451  @note the underlying RTOS may have a limit to the maximum wait time
452  due to internal 32-bit computations, but this is guaranteed to work if the
453  delay is <= 0x7fffffff milliseconds (~24 days). If the limit is exceeded,
454  it may return with an immediate error, or wait for the maximum delay.
455 
456  @note You cannot call this function from ISR context.
457  @deprecated Static methods only affecting current thread cause confusion. Replaced by ThisThread::sleep_until.
458  */
459  MBED_DEPRECATED_SINCE("mbed-os-5.10",
460  "Static methods only affecting current thread cause confusion. "
461  "Replaced by ThisThread::sleep_until.")
462  static osStatus wait_until(uint64_t millisec);
463 
464  /** Pass control to next thread that is in state READY.
465  @return status code that indicates the execution status of the function.
466 
467  @note You cannot call this function from ISR context.
468  @deprecated Static methods only affecting current thread cause confusion. Replaced by ThisThread::sleep_until.
469  */
470  MBED_DEPRECATED_SINCE("mbed-os-5.10",
471  "Static methods only affecting current thread cause confusion. "
472  "Replaced by ThisThread::yield.")
473  static osStatus yield();
474 
475  /** Get the thread id of the current running thread.
476  @return thread ID for reference by other functions or NULL in case of error.
477 
478  @note You may call this function from ISR context.
479  @deprecated Static methods only affecting current thread cause confusion. Replaced by ThisThread::get_id.
480  Use Thread::get_id for the ID of a specific Thread.
481  */
482  MBED_DEPRECATED_SINCE("mbed-os-5.10",
483  "Static methods only affecting current thread cause confusion. "
484  "Replaced by ThisThread::get_id. Use Thread::get_id for the ID of a specific Thread.")
485  static osThreadId gettid();
486 
487  /** Attach a function to be called by the RTOS idle task
488  @param fptr pointer to the function to be called
489 
490  @note You may call this function from ISR context.
491  @deprecated Static methods affecting system cause confusion. Replaced by Kernel::attach_idle_hook.
492  */
493  MBED_DEPRECATED_SINCE("mbed-os-5.10",
494  "Static methods affecting system cause confusion. "
495  "Replaced by Kernel::attach_idle_hook.")
496  static void attach_idle_hook(void (*fptr)(void));
497 
498  /** Attach a function to be called when a task is killed
499  @param fptr pointer to the function to be called
500 
501  @note You may call this function from ISR context.
502  @deprecated Static methods affecting system cause confusion. Replaced by Kernel::attach_thread_terminate_hook.
503  */
504  MBED_DEPRECATED_SINCE("mbed-os-5.10",
505  "Static methods affecting system cause confusion. "
506  "Replaced by Kernel::attach_thread_terminate_hook.")
507  static void attach_terminate_hook(void (*fptr)(osThreadId id));
508 
509  /** Thread destructor
510  *
511  * @note You cannot call this function from ISR context.
512  */
513  virtual ~Thread();
514 
515 private:
516  // Required to share definitions without
517  // delegated constructors
518  void constructor(osPriority priority = osPriorityNormal,
519  uint32_t stack_size = OS_STACK_SIZE,
520  unsigned char *stack_mem = NULL,
521  const char *name = NULL);
522  void constructor(mbed::Callback<void()> task,
523  osPriority priority = osPriorityNormal,
524  uint32_t stack_size = OS_STACK_SIZE,
525  unsigned char *stack_mem = NULL,
526  const char *name = NULL);
527  void constructor(uint32_t tz_module,
528  osPriority priority = osPriorityNormal,
529  uint32_t stack_size = OS_STACK_SIZE,
530  unsigned char *stack_mem = NULL,
531  const char *name = NULL);
532  static void _thunk(void *thread_ptr);
533 
534  mbed::Callback<void()> _task;
535  osThreadId_t _tid;
536  osThreadAttr_t _attr;
537  bool _dynamic_stack;
538  Semaphore _join_sem;
539  mutable Mutex _mutex;
540  mbed_rtos_storage_thread_t _obj_mem;
541  bool _finished;
542 };
543 /** @}*/
544 /** @}*/
545 }
546 #endif
547 
548 
The Thread class allow defining, creating, and controlling thread functions in the system...
Definition: Thread.h:85
uint32_t flags_set(uint32_t flags)
Set the specified Thread Flags for the thread.
Waiting for a memory pool.
Definition: Thread.h:342
int32_t signal_set(int32_t signals)
Set the specified Thread Flags for the thread.
The Semaphore class is used to manage and protect access to a set of shared resources.
Definition: Semaphore.h:46
osStatus terminate()
Terminate execution of a thread and remove it from Active Threads.
osStatus set_priority(osPriority priority)
Set priority of an active thread.
NOT USED (Mail is implemented as MemoryPool and Queue)
Definition: Thread.h:348
uint32_t free_stack() const
Get the currently unused stack memory for this Thread.
static osStatus yield()
Pass control to next thread that is in state READY.
static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever)
Wait for one or more Thread Flags to become signaled for the current RUNNING thread.
Thread(osPriority priority=osPriorityNormal, uint32_t stack_size=OS_STACK_SIZE, unsigned char *stack_mem=NULL, const char *name=NULL)
Allocate a new thread without starting execution.
Definition: Thread.h:97
Waiting for a mutex event to occur.
Definition: Thread.h:340
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:168
static void attach_terminate_hook(void(*fptr)(osThreadId id))
Attach a function to be called when a task is killed.
Waiting for message to be send.
Definition: Thread.h:344
Callback< R()> callback(R(*func)()=0)
Create a callback class with type inferred from the arguments.
Definition: Callback.h:3848
Waiting for message to arrive.
Definition: Thread.h:343
State
State of the Thread.
Definition: Thread.h:332
Waiting for a thread flag to be set.
Definition: Thread.h:338
osStatus join()
Wait for thread to terminate.
Waiting for a event flag to be set.
Definition: Thread.h:339
void attach_thread_terminate_hook(void(*fptr)(osThreadId_t id))
Attach a function to be called when a thread terminates.
Waiting for thread to join.
Definition: Thread.h:337
osPriority get_priority() const
Get priority of an active thread.
The Mutex class is used to synchronize the execution of threads.
Definition: Mutex.h:66
uint32_t used_stack() const
Get the currently used stack memory for this Thread.
State get_state() const
State of this Thread.
static osStatus wait_until(uint64_t millisec)
Wait until a specified time in millisec The specified time is according to Kernel::get_ms_count().
Ready to run.
Definition: Thread.h:334
Waiting for a delay to occur.
Definition: Thread.h:336
const char * get_name() const
Get thread name.
Waiting for a semaphore event to occur.
Definition: Thread.h:341
Thread(uint32_t tz_module, osPriority priority=osPriorityNormal, uint32_t stack_size=OS_STACK_SIZE, unsigned char *stack_mem=NULL, const char *name=NULL)
Allocate a new thread without starting execution.
Definition: Thread.h:117
static osStatus wait(uint32_t millisec)
Wait for a specified time period in milliseconds Being tick-based, the delay will be up to the specif...
osStatus start(mbed::Callback< void()> task)
Starts a thread executing the specified function.
static int32_t signal_clr(int32_t signals)
Clears the specified Thread Flags of the currently running thread.
static void attach_idle_hook(void(*fptr)(void))
Attach a function to be called by the RTOS idle task.
osThreadId_t get_id() const
Get thread id.
Callback class based on template specialization.
Definition: Callback.h:39
The task has been deleted or not started.
Definition: Thread.h:351
static osThreadId gettid()
Get the thread id of the current running thread.
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...
uint32_t max_stack() const
Get the maximum stack memory usage to date for this Thread.
uint32_t stack_size() const
Get the total stack memory size for this Thread.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.