-
Notifications
You must be signed in to change notification settings - Fork 450
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
关于在shellTask任务中添加延时,释放CPU占用,让空闲任务得到执行 #182
Comments
这个设计是期望实现的 shell->read 接口中,有进行操作系统的任务调度 |
感谢回复,这个我看了在esp32中是没问题的,但是好多底层驱动设计的和RTOS完全解耦了; |
这种情况就可以在实现的 shell->read 接口中进行任务调度,就比如说最简单的加 sleep,就可以放在 shell->read 的实现中 |
了解了,那我就先在uart_isr和uart_read中添加一个钩子函数吧,一个用于发送信号量和等待信号量操作,尽量降低驱动和rtos耦合吧 |
Hi NevermindZZT 大佬好
在下面这个代码中,如果使用rtos则是一个while(1)的死循环,如果rtos中还有一个空闲任务,优先级比这个任务优先级低,则永远得不到执行
void shellTask(void *param)
{
Shell *shell = (Shell *)param;
char data;
#if SHELL_TASK_WHILE == 1
while(1)
{
#endif
if (shell->read && shell->read(&data, 1) == 1)
{
shellHandler(shell, data);
}
#if SHELL_TASK_WHILE == 1
}
#endif
}
大佬是否考虑添加一个delay,用于释放CPU资源;
例如在配置文件中加一个宏定义
#define SHELL_DELAY() vTaskDealy( (5) / portTICK_PERIOD_MS )
void shellTask(void *param)
{
Shell *shell = (Shell *)param;
char data;
#if SHELL_TASK_WHILE == 1
while(1)
{
#endif
if (shell->read && shell->read(&data, 1) == 1)
{
shellHandler(shell, data);
}
#if SHELL_TASK_WHILE == 1
SHELL_DELAY();
}
#endif
}
The text was updated successfully, but these errors were encountered: