-
Notifications
You must be signed in to change notification settings - Fork 5.3k
add support for thread usage #8918
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
1,201 changes: 1,035 additions & 166 deletions
1,201
bsp/stm32/stm32f427-robomaster-a/project.uvprojx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2024-2024, RT-Thread Development Team | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Change Logs: | ||
* Date Author Notes | ||
* 2024-05-9 Dyyt587 the first version | ||
*/ | ||
|
||
#include "cpuusage.h" | ||
//#ifdef RT_USING_CPU_USAGE | ||
#if 1 | ||
static rt_tick_t pause_tick = 0; | ||
|
||
/** | ||
* @brief pause usage measure | ||
* | ||
* @note reduce scheduler time consuming | ||
*/ | ||
void rt_usage_measure_pause(void) | ||
{ | ||
pause_tick = rt_tick_get(); | ||
} | ||
/** | ||
* @brief start usage measure | ||
* | ||
* @param from wait to turn on | ||
* @param to turn to be | ||
*/ | ||
void rt_usage_measure_start(struct rt_thread *from, struct rt_thread *to) | ||
{ | ||
/* to avoid scheduler time consuming */ | ||
from->duration_tick += pause_tick - from->last_start_tick; | ||
|
||
to->last_start_tick = rt_tick_get(); | ||
} | ||
|
||
|
||
|
||
#endif /* RT_USING_CPU_USAGE */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024-2024, RT-Thread Development Team | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Change Logs: | ||
* Date Author Notes | ||
* 2024-05-9 Dyyt587 the first version | ||
*/ | ||
|
||
#ifndef CPU_USAGE_H | ||
#define CPU_USAGE_H | ||
|
||
#include <rtthread.h> | ||
#include "ulog_def.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
建议参考 FMT 的算法设计,用更高精度的时间戳去计算时间间隔
https://github.com/Firmament-Autopilot/FMT-Firmware/blob/9de2ddb736ceaea09b4ecc36a6b5bb151436404a/src/module/system/statistic.c#L65
rt-thread 最新添加的 ktme 就挺合适的。
rt-thread/components/drivers/ktime/inc/ktime.h
Lines 37 to 44 in d0cf646
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.
感谢提供的建议,我会采纳并修改
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.
@Dyyt587 这个PR还在跟进吗?
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.
目前没有更进了