Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a really dumb question from someone unfamiliar with the kernel's futex implementation, so bear with me. In userspace locks (e.g. in parking_lot), wait queues can be threaded through nodes allocated on the stack of each waiting thread, so no static or dynamic allocation of wait queue nodes is necessary. Is it possible to allocate wait queue nodes on the kernel stacks of waiting threads as well?


> Is it possible to allocate wait queue nodes on the kernel stacks of waiting threads as well?

Yes, this is exactly what's done. The queue node is an declared as a local variable in kernel code, i.e. on the kernel stack, and its address is passed to the wait function which links it into the waitqueue and then blocks in the scheduler.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: