
Example usage of the mbed_stats_thread_get_each API.
main.cpp@25:dcd2d6d9a0e5, 2019-10-23 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Oct 23 19:02:34 2019 +0100
- Revision:
- 25:dcd2d6d9a0e5
- Parent:
- 15:6bca4e2b1a14
Merge https://github.com/ARMmbed/mbed-os-example-thread-statistics
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-thread-statistics
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 15:6bca4e2b1a14 | 1 | /* Copyright (c) 2018 Arm Limited |
mbed_official | 15:6bca4e2b1a14 | 2 | * |
mbed_official | 15:6bca4e2b1a14 | 3 | * SPDX-License-Identifier: Apache-2.0 |
mbed_official | 15:6bca4e2b1a14 | 4 | * |
mbed_official | 15:6bca4e2b1a14 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 15:6bca4e2b1a14 | 6 | * you may not use this file except in compliance with the License. |
mbed_official | 15:6bca4e2b1a14 | 7 | * You may obtain a copy of the License at |
mbed_official | 15:6bca4e2b1a14 | 8 | * |
mbed_official | 15:6bca4e2b1a14 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 15:6bca4e2b1a14 | 10 | * |
mbed_official | 15:6bca4e2b1a14 | 11 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 15:6bca4e2b1a14 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 15:6bca4e2b1a14 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 15:6bca4e2b1a14 | 14 | * See the License for the specific language governing permissions and |
mbed_official | 15:6bca4e2b1a14 | 15 | * limitations under the License. |
mbed_official | 15:6bca4e2b1a14 | 16 | */ |
mbed_official | 0:25c062a4a1e6 | 17 | #include "mbed.h" |
mbed_official | 0:25c062a4a1e6 | 18 | |
mbed_official | 0:25c062a4a1e6 | 19 | #if !defined(MBED_THREAD_STATS_ENABLED) |
mbed_official | 0:25c062a4a1e6 | 20 | #error "Stats not enabled" |
mbed_official | 0:25c062a4a1e6 | 21 | #endif |
mbed_official | 0:25c062a4a1e6 | 22 | |
mbed_official | 0:25c062a4a1e6 | 23 | #define MAX_THREAD_STATS 0x8 |
mbed_official | 0:25c062a4a1e6 | 24 | |
mbed_official | 0:25c062a4a1e6 | 25 | int main() |
mbed_official | 0:25c062a4a1e6 | 26 | { |
mbed_official | 0:25c062a4a1e6 | 27 | mbed_stats_thread_t *stats = new mbed_stats_thread_t[MAX_THREAD_STATS]; |
mbed_official | 0:25c062a4a1e6 | 28 | int count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS); |
mbed_official | 0:25c062a4a1e6 | 29 | |
mbed_official | 0:25c062a4a1e6 | 30 | for(int i = 0; i < count; i++) { |
mbed_official | 0:25c062a4a1e6 | 31 | printf("ID: 0x%x \n", stats[i].id); |
mbed_official | 0:25c062a4a1e6 | 32 | printf("Name: %s \n", stats[i].name); |
mbed_official | 0:25c062a4a1e6 | 33 | printf("State: %d \n", stats[i].state); |
mbed_official | 0:25c062a4a1e6 | 34 | printf("Priority: %d \n", stats[i].priority); |
mbed_official | 0:25c062a4a1e6 | 35 | printf("Stack Size: %d \n", stats[i].stack_size); |
mbed_official | 0:25c062a4a1e6 | 36 | printf("Stack Space: %d \n", stats[i].stack_space); |
mbed_official | 0:25c062a4a1e6 | 37 | printf("\n"); |
mbed_official | 0:25c062a4a1e6 | 38 | } |
mbed_official | 0:25c062a4a1e6 | 39 | return 0; |
mbed_official | 0:25c062a4a1e6 | 40 | } |