Skip to content

Commit 1fa0830

Browse files
committed
Update to RTOS page and Kernel namespace documentation
1 parent 852ad90 commit 1fa0830

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

docs/reference/api/rtos/Kernel.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Kernel Interface functions
2+
3+
Kernel namespace implements functions to read RTOS information. Currently it implements one function to read the current RTOS kernel millisecond tick count.
4+
5+
### Kernel namespace reference
6+
7+
[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/namespacertos_1_1Kernel.html)
8+
9+
### get_ms_count() example
10+
Currently kernel implements one function named get_ms_count() to read the current RTOS kernel millisecond tick count.
11+
The below code snippet demonstrates usage of get_ms_count() function to calculate the elapsed time.
12+
13+
```
14+
void send_data()
15+
{
16+
// 64-bit time doesn't wrap for half a billion years, at least
17+
uint64_t now = Kernel::get_ms_count();
18+
//do some operations
19+
// ...
20+
21+
uint64_t later = Kernel::get_ms_count();
22+
23+
//calculate millisecs elapsed
24+
uint64_t elapsed_ms = later - now;
25+
}
26+
```

docs/reference/api/rtos/rtos.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<h2 id="rtos-api">RTOS overview</h2>
22

3-
The Arm Mbed RTOS is a C++ wrapper over the Keil RTX code. For more information about Keil RTX, check [the Keil CMSIS-RTOS tutorial](https://github.com/ARM-software/CMSIS/raw/master/CMSIS/Documentation/RTX/CMSIS_RTOS_Tutorial.pdf) and [the element14 introduction to Keil RTX](https://www.element14.com/community/docs/DOC-46650/l/arm-keil-rtx-real-time-operating-system-overview). You can use these resources as a general introduction to RTOS principles; it is important to be familiar with the concepts behind an RTOS in order to understand this guide.
3+
The Arm Mbed RTOS is a wrapper over the Keil RTX code. The wrapper provides C++ abstraction for RTX objects like thread, synchronization objects and timer. It also provides interfaces for attaching application
4+
specific idle hook function and to read the tick count from OS. The Arm Mbed RTOS layer also implements handlers for RTX errors and report them into Mbed-OS error handling system using Mbed-OS defined error status.
5+
6+
For more information about Keil RTX, check [the Keil CMSIS-RTOS tutorial](https://github.com/ARM-software/CMSIS/raw/master/CMSIS/Documentation/RTX/CMSIS_RTOS_Tutorial.pdf) and [the element14 introduction to Keil RTX](https://www.element14.com/community/docs/DOC-46650/l/arm-keil-rtx-real-time-operating-system-overview). You can use these resources as a general introduction to RTOS principles; it is important to be familiar with the concepts behind an RTOS in order to understand this guide.
47

58
The code of the Mbed RTOS can be found in the [`mbed-os`](https://github.com/ARMmbed/mbed-os) repository, in the [RTOS subdirectory](https://github.com/ARMmbed/mbed-os/tree/master/rtos). See [the Doxygen](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/group__rtos.html) for more information.
69

7-
#### SysTick
10+
#### RTOS Ticker
11+
Platforms using RTOS, including Mbed OS, need a mechanism for counting the time and scheduling tasks. This is usually done by a timer which generates periodic interrupts and is called system tick timer.
12+
Under Mbed OS, we call this mechanism RTOS ticker.
813

9-
System tick timer (SysTick) is a standard timer available on most Cortex-M cores. Its main purpose is to raise an interrupt with set frequency (usually 1ms). You can use it to perform any task in the system, but for platforms using RTOS, including Mbed OS, it provides an interval for the OS for counting the time and scheduling tasks.
14+
SysTick is a standard timer available on most Cortex-M cores. Its main purpose is to raise an interrupt with set frequency (usually 1ms). In addition, many Mbed OS platforms
15+
implement timers as part of peripherals. Mbed OS supports using SysTick or the peripheral timers as RTOS ticker.
1016

11-
Mbed OS uses default SysTick source for most targets, but you can override that using the [Tick API](http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__TickAPI.html) that CMSIS-RTOS2 provides. In which case you'll need to provide your own source of the interrupts.
17+
Mbed OS platforms uses SysTick as the default RTOS ticker, but if you want to use one of the peripheral timers as your RTOS ticker you can do so by overriding the default SysTick timer using the [Tick API](http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__TickAPI.html) that CMSIS-RTOS2 provides. For example, see [Low Power Ticker](/docs/development/reference/low-power-ticker.html) on how to use external low power timer to perform power efficient timing operations that only requires millisecond accuracy.
1218

1319
#### RTOS APIs
1420

@@ -23,6 +29,8 @@ The RTOS APIs handle creation and destruction of threads in Arm Mbed OS 5, as we
2329
- [RtosTimer](/docs/development/reference/rtostimer.html): A deprecated class used to control timer functions in the system.
2430
- [EventFlags](/docs/development/reference/eventflags.html): An event channel that provides a generic way of notifying other threads about conditions or events.
2531
- [Event](/docs/development/reference/event.html): The queue to store events, extract them and excute them later.
32+
- [ConditionVariable](/docs/development/reference/conditionvariable.html): The ConditionVariable class provides a mechanism to safely wait for or signal state changes.
33+
- [Kernel](/docs/development/reference/kernel.html): Kernel namespace implements functions to control or read RTOS information like tick count.
2634

2735
##### Default timeouts
2836

0 commit comments

Comments
 (0)