-
Notifications
You must be signed in to change notification settings - Fork 178
Update to RTOS page and Kernel namespace documentation #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
f1f5a27
a320614
4ac6341
bce1701
1acfdba
6072ae3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Kernel Interface functions | ||
|
||
Kernel namespace implements functions to read RTOS information. Currently it implements one function to read the current RTOS kernel millisecond tick count. | ||
|
||
### Kernel namespace reference | ||
|
||
[](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/namespacertos_1_1Kernel.html) | ||
|
||
### get_ms_count() example | ||
Currently kernel implements one function named get_ms_count() to read the current RTOS kernel millisecond tick count. | ||
The below code snippet demonstrates usage of get_ms_count() function to calculate the elapsed time. | ||
|
||
``` | ||
void send_data() | ||
{ | ||
// 64-bit time doesn't wrap for half a billion years, at least | ||
uint64_t now = Kernel::get_ms_count(); | ||
//do some operations | ||
// ... | ||
|
||
uint64_t later = Kernel::get_ms_count(); | ||
|
||
//calculate millisecs elapsed | ||
uint64_t elapsed_ms = later - now; | ||
} | ||
``` |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
<h2 id="rtos-api">RTOS overview</h2> | ||
|
||
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. | ||
Mbed-OS RTOS provide C++ APIs to manage objects like thread, synchronization objects and timer. It also provides interfaces for attaching application | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kegilbert - Change done, please review. |
||
specific idle hook function, read the OS tick count and implements functionality to report RTOS errors. | ||
|
||
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. | ||
|
||
#### SysTick | ||
#### RTOS Ticker | ||
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. | ||
Under Mbed OS, we call this mechanism RTOS ticker. | ||
|
||
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. | ||
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 | ||
implement timers as part of peripherals. Mbed OS supports using SysTick or the peripheral timers as RTOS ticker. | ||
|
||
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. | ||
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. 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. | ||
|
||
#### RTOS APIs | ||
|
||
|
@@ -21,8 +25,10 @@ The RTOS APIs handle creation and destruction of threads in Arm Mbed OS 5, as we | |
- [MemoryPool](/docs/development/reference/memorypool.html): This class that you can use to define and manage fixed-size memory pools | ||
- [Mail](/docs/development/reference/mail.html): The API that provides a queue combined with a memory pool for allocating messages. | ||
- [RtosTimer](/docs/development/reference/rtostimer.html): A deprecated class used to control timer functions in the system. | ||
- [EventFlags](/docs/development/reference/eventflags.html): An event channel that provides a generic way of notifying other threads about conditions or events. | ||
- [EventFlags](/docs/development/reference/eventflags.html): An event channel that provides a generic way of notifying other threads about conditions or events. Some EventFlags functions are callable from ISR context and each EventFlags objects can support up to 31 flags. | ||
- [Event](/docs/development/reference/event.html): The queue to store events, extract them and excute them later. | ||
- [ConditionVariable](/docs/development/reference/conditionvariable.html): The ConditionVariable class provides a mechanism to safely wait for or signal a single state change. ConditionVariable functions are not callable from ISR context. | ||
- [Kernel](/docs/development/reference/kernel.html): Kernel namespace implements functions to control or read RTOS information like tick count. | ||
|
||
##### Default timeouts | ||
|
||
|
@@ -51,21 +57,6 @@ Each `Thread` can wait for signals and be notified of events: | |
|
||
[](https://os.mbed.com/teams/mbed_example/code/rtos_signals/file/476186ff82cf/main.cpp) | ||
|
||
##### Status and error codes | ||
|
||
The CMSIS-RTOS functions will return the following statuses: | ||
|
||
- `osOK`: function completed; no event occurred. | ||
- `osEventSignal`: function completed; signal event occurred. | ||
- `osEventMessage`: function completed; message event occurred. | ||
- `osEventMail`: function completed; mail event occurred. | ||
- `osEventTimeout`: function completed; timeout occurred. | ||
- `osErrorParameter`: a mandatory parameter was missing or specified an incorrect object. | ||
- `osErrorResource`: a specified resource was not available. | ||
- `osErrorTimeoutResource`: a specified resource was not available within the timeout period. | ||
- `osErrorISR`: the function cannot be called from interrupt service routines (ISR). | ||
- `osErrorISRRecursive`: function called multiple times from ISR with same object. | ||
- `osErrorPriority`: system cannot determine priority or thread has illegal priority. | ||
- `osErrorNoMemory`: system is out of memory; it was impossible to allocate or reserve memory for the operation. | ||
- `osErrorValue`: value of a parameter is out of range. | ||
- `osErrorOS`: unspecified RTOS error - runtime error but no other error message fits. | ||
##### Status and Error codes | ||
Mbed OS error handling system assigns specific error codes for RTOS related erros. See [Error Handling](/docs/development/reference/error-handling.html) | ||
for more information on RTOS errors reported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This link doesn't work for me. Is there a code dependency?