Skip to content
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

[features]: 实现中断上下文打印输出特性支持 #149

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jhbdream
Copy link

  1. 判断当前log输出上下文
  2. 中断上下文与任务上下文使用单独输出buffer
  3. 不支持中断嵌套模式下中断输出调用
  4. 添加接口判断是否处于中断上下文

hi 你好:
我希望实现该log日志输出支持在中断上下文进行,相关代码修改请问是否合适

  1. 判断当前log输出上下文
  2. 中断上下文与任务上下文使用单独输出buffer
  3. 不支持中断嵌套模式下中断输出调用
  4. 添加接口判断是否处于中断上下文
@armink
Copy link
Owner

armink commented Nov 15, 2023

这个功能是否可以做成选配,默认关闭?

毕竟还有些非 RTOS 如 Linux 用户在用

@jhbdream
Copy link
Author

如果主体方案您认为可行 我可以做成通过宏定义进行配置选择启用;

@armink
Copy link
Owner

armink commented Nov 16, 2023

实现上还得斟酌一下,比如:

  • 中断上下文执行也需要加锁,只是锁换成了锁全局中断
  • 中断日志也得又独立日志 buf,与常规日志分开,避免可重入问题

也可以看下 ulog 的实现, https://github.com/RT-Thread/rt-thread/blob/master/components/utilities/ulog/ulog.c

  1. 添加中断上下文加锁、释放锁接口
@jhbdream
Copy link
Author

jhbdream commented Nov 19, 2023

您好:
参考 ulog.c 文件,完成如下特性实现考虑

  1. 增加移植接口 elog_port_interrupt_get_nest 用于获取当前运行上下文是否为中断环境
  2. 增加移植接口 elog_port_output_lock_isr elog_port_output_unlock_isr 用于在中断上下文下进行加锁 解锁操作
  3. 增加中断上下文输出buffer定义和线程上下文buffer定义 isr_log_buf thread_log_buf 根据 elog_port_interrupt_get_nest 接口获取状态使用对应buffer输出

对于当前代码中的 output_is_locked_before_disableoutput_is_locked_before_enable 还没有考虑好如何处理

@jhbdream
Copy link
Author

还有一点疑问想请教 , 这里的设计为什么不使用栈空间开辟的buffer进行格式化输出,而是共享一个全局buffer;
如果使用栈空间输出buffer 可以避免一些锁的使用

@armink
Copy link
Owner

armink commented Nov 19, 2023

还有一点疑问想请教 , 这里的设计为什么不使用栈空间开辟的buffer进行格式化输出,而是共享一个全局buffer; 如果使用栈空间输出buffer 可以避免一些锁的使用

主要这样会增加各个线程堆栈空间,这样在嵌入式设备里是不能接受的

@jhbdream
Copy link
Author

完成基本功能添加和宏定义隔离,您对整个系统更加熟悉 希望可以把关看下

  1. 添加宏定义控制是否启用中断输出支持
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants