PCOMM的中断程序是否需要放入一个单独线程中执行

mansea163 2011-08-24 10:33:50
pcomm中的sio_cnt_irq函数会调用一个中断函数。我是在这个中断函数中读取串口,串口数据从单片机发过来。并且这个中断
函数放在主窗体的cpp中。

这样的话,如果在主窗体中执行其他操作,比如读取数据库的时候,会不会导致中断函数执行延迟而丢失发进来的串口数据。

是不是不要把中断程序放入一个单独线程中?

谁了解该中断程序的原理?

谢谢
...全文
176 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mansea163 2011-09-19
  • 打赏
  • 举报
回复
大家参看这篇文章 我看不太懂
mansea163 2011-09-19
  • 打赏
  • 举报
回复
顶起来 这个问题还是没搞清楚
sio_cnt_irq、被调用的中断函数和数据库读写代码都放在一个cpp文件中。当正在读写数据库时(量大,可能需要时间),如果串口有数据送进来,是否会导致接收串口数据延迟??
PCOMM是不是自动多线程的?
谁能说清楚。谢谢
mansea163 2011-08-24
  • 打赏
  • 举报
回复
另外附上sio_cnt_irq的一点资料,大家帮忙分析一下:
Remarks

Under Win32 (9x/NT/XP/2000/2003/Vista), the design of event (usually caused by interrupt) sets an event flag on, every time the interrupt occurs, and invokes the event service routine, which is triggered by a particular event. With this event scheme, while system loading is heavy, it often happens that several consecutive interrupts, which set the same event flag on, will be just handled once.

Due to the uncertainty of such an event scheme, functions like sio_break_irq(), sio_cnt_irq(), sio_Tx_empty_irq() and sio_modem_irq() (or named sio_xxx_irq() functions in short) may not respond the exact times of interrupt occurrence.

In addition, within sio_xxx_irq() event service routine, there have no reentrance problem and thus no prohibition of functions like printf().

Only '1' is available for the count parameter of sio_cnt_irq().

For VB, the functions, sio_xxx_irq() are not supported.


mansea163 2011-08-24
  • 打赏
  • 举报
回复
我的问题的核心是:由于单片机发过来数据是随时的,所以会不会有这样的情况:单片机已经发出数据,而主程序此时正在执行读取数据库的操作(假设有几千个数据要读出来绘图,需要一段时间),那么主程序会不会执行完数据库操作才转到该处理函数,从而响应延迟?
zzbinfo 2011-08-24
  • 打赏
  • 举报
回复
你这里说的其实是回调函数,这个是不需要放到单独的线程中的。当有数据要接收的时候就会自动调用你的处理函数接收处理。而不是要把你的主进程中断了来处理接收事件。至于接收的串口数据会不会丢失,主要还是看你的这个处理函数是怎么处理的。
mansea163 2011-08-24
  • 打赏
  • 举报
回复
我想了一下 觉得还是需要放在一个单独线程中 否则如果主程序执行某个长时间的操作 那么串口的中断函数执行肯定就被延迟了
zzbinfo 2011-08-24
  • 打赏
  • 举报
回复
不会。

1,316

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧