Skip to content

Kernel documentation updated with new additions to Kernel namespace #792

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

Merged
merged 2 commits into from
Oct 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/api/rtos/Kernel.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## Kernel interface functions

The Kernel namespace implements functions to read RTOS information. Currently it implements one function to read the current RTOS kernel millisecond tick count.
The Kernel namespace implements interfaces to attach a function to some kernel events and also to read the kernel tick count.

### Kernel namespace reference

[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/namespacertos_1_1_kernel.html)

### `get_ms_count()` example

Kernel implements one function named `get_ms_count()` to read the current RTOS kernel millisecond tick count. The below code snippet demonstrates use of the `get_ms_count()` function to calculate the elapsed time:
The function `get_ms_count()` can be used to read the current RTOS kernel millisecond tick count. The below code snippet demonstrates use of the `get_ms_count()` function to calculate the elapsed time:

```
void send_data()
Expand All @@ -23,4 +23,17 @@ void send_data()
//calculate millisecs elapsed
uint64_t elapsed_ms = later - now;
}

```

### `attach_idle_hook()` example

The function `attach_idle_hook()` can be used to attach a function to be called by the RTOS idle task. The below code snippet demostrates the usage.

[![View Example](https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-example-kernel-hooks)](https://github.com/ARMmbed/mbed-os-example-kernel-hooks/blob/master/main.cpp)

### `attach_thread_terminate_hook()` example

The function `attach_thread_terminate_hook()` can be used to attach a function to be called when a thread terminates.

[![View Example](https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-example-kernel-hooks)](https://github.com/ARMmbed/mbed-os-example-kernel-hooks/blob/master/main.cpp)