韦东山

Results 1 comments of 韦东山

> 有个题外话。导致这个问题的直接原因 —— 调用 `rt_thread_suspend()` 挂起其它线程。从 API 的使用场景来说应该是滥用了吧?这个实现可能最初假定就是在 `rt_schedule()` 恢复运行时去做这些逻辑。因此我有点好奇这种不是主动挂起的场景是否具有合理性呢? > > https://github.com/RT-Thread/rt-thread/blob/307e9e5e98675da7c1fa32f15ab4130ca5f73a8a/src/thread.c#L966-L982 > > > Do not use the rt_thread_suspend to suspend other threads. 使用rt_thread_suspend 暂停其他线程确实不是一个好的编程习惯,因为你不知道别的线程暂停时需要做什么额外的工作。比如要暂停一个音乐播放器,你使用rt_thread_suspend 的话,也许它会发出一个恒定不变的声音(比如使用PWM播放音乐时就会这样)。 这里提到的信号bug,也会出现在“主动阻塞的场景”里,比如thread1调用rt_thread_delay,然后thread2给thread1发信号:会唤醒thread1,但是thread1并不会执行信号函数。