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.
拉取/合并请求描述:(PR description)
[
如果一个线程不是调用rt_thread_delay等函数主动进入挂起状态,不是在rt_schedule函数中放弃运行,
那么其他线程给它发信号时,它是不会执行信号处理函数的。
这个Bug的原因在于:在_signal_deliver函数中,发现目标线程处于挂起状态时,
只做了3件事:把它唤醒、设置线程状态为RT_THREAD_STAT_SIGNAL_PENDING、调用rt_schedule。
我们期望目标线程被唤醒后,从rt_schedule继续运行时,发现线程状态为RT_THREAD_STAT_SIGNAL_PENDING时调用信号处理函数。
但是,目标线程挂起时,不一定是在rt_schedule函数中放弃运行,比如它可能是被其他线程调用rt_thread_suspend挂起的。
这时候,目标线程不会执行信号处理函数。
为什么提交这份PR (why to submit this PR)
你的解决方案是什么 (what is your solution)
修改了src/signal.c,即使目标线程处于挂起状态,也是去修改它的栈。
在什么测试环境下测试通过 (what is the test environment)
可以如下复现这个Bug:创建2个线程,让thread2挂起thread1,然后给thread1发信号。示例代码如下:
`static void thread1_entry(void *parameter)
{
const char *thread_name = parameter;
int cnt = 0;
}
/* 线程2的入口函数 */
static void thread2_entry(void *parameter)
{
const char *thread_name = parameter;
int cnt = 0;
}`
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up