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

[question] wait_for_butex 还是有可能会让正在执行的pthread陷入内核? #2598

Closed
ilixiaocui opened this issue Apr 11, 2024 · 4 comments

Comments

@ilixiaocui
Copy link

ilixiaocui commented Apr 11, 2024

wait_for_butex中使用的waiter_lock调用了futex,在一些场景下还是会使得正在执行的pthread陷入内核,而无法执行其他bthread任务吧?
image

@TousakaRin
Copy link
Contributor

是的,可能会陷入内核,但是即便不发起任何syscall也有可能被内核调度走呀

@ilixiaocui
Copy link
Author

ilixiaocui commented Apr 25, 2024

是的,可能会陷入内核,但是即便不发起任何syscall也有可能被内核调度走呀

主要是看到这里的疑问:也就是使用butex也还是有概率会导致pthread被挂起的?但是由于这里的临界区很小,被挂起的概率就小很多?

image

@TousakaRin
Copy link
Contributor

这里想表达的是: 如果一个bthread阻塞在butex上,它会被添加到butex的等待队列,不论它将要等待多久,这个pthread在操作完之后都可以立即去继续执行其他bthread,反之如果阻塞在mutex上,这个就需要等待mutex被释放之后才能继续执行其他bthread。前面的case pthread 被阻塞的概率和时长,与这个butex被释放的时间无关。

@ilixiaocui
Copy link
Author

这里想表达的是: 如果一个bthread阻塞在butex上,它会被添加到butex的等待队列,不论它将要等待多久,这个pthread在操作完之后都可以立即去继续执行其他bthread,反之如果阻塞在mutex上,这个就需要等待mutex被释放之后才能继续执行其他bthread。前面的case pthread 被阻塞的概率和时长,与这个butex被释放的时间无关。

了解了 感谢 ~

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

No branches or pull requests

2 participants