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