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

idle线程主动挂起行为是何用意呢? #8446

Closed
daguobayern opened this issue Dec 29, 2023 · 3 comments · Fixed by #8456
Closed

idle线程主动挂起行为是何用意呢? #8446

daguobayern opened this issue Dec 29, 2023 · 3 comments · Fixed by #8456
Assignees
Labels
bug This PR/issue is a bug in the current code.

Comments

@daguobayern
Copy link

daguobayern commented Dec 29, 2023

最新master分支上的idle.c文件中的rt_defunct_execute函数,该函数中有如下代码

        while (rt_atomic_load(&(thread->ref_count)))
        {
            rt_thread_delay(5);
        }

问题:

1,此处循环原子读ref_count是想达到什么目的呢,在idle线程初始化里面ref_count初始化为0,所以不会进入该循环,这里正确用法是什么呢,若此值非0,是不是在其他线程里面会一直减这个ref_count呢?
2,非0情况下,idle线程就主动sleep,这里不是就挂起idle线程了吗,idle是允许被挂起的吧

@FragrantRye
Copy link
Contributor

看起来是想实现一个让权等待,但是本来都在idle线程里了,让给谁呢?

@BernardXiong
Copy link
Member

哎,是有问题的,是bug

image

@BernardXiong BernardXiong added the bug This PR/issue is a bug in the current code. label Dec 30, 2023
@xqyjlj
Copy link
Contributor

xqyjlj commented Dec 30, 2023

这是之前调试自旋锁的时候加的线程引用计数(防止释放线程的时候引用计数没释放干净),正常情况下线程ref进这里是0的。我下一个版本把线程引用计数删掉好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This PR/issue is a bug in the current code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants