LWN.net Logo

EPOLL_CTL_DISABLE and multithreaded applications

EPOLL_CTL_DISABLE and multithreaded applications

Posted Oct 25, 2012 5:14 UTC (Thu) by cyanit (guest, #86671)
Parent article: EPOLL_CTL_DISABLE and multithreaded applications

Other solution: pass a pointer to a userspace reference count in a new EPOLL_CTL_ADD_RC, which is incremented in the kernel under the epoll lock when an event concerning that fd is returned to userspace.

This way, after EPOLL_CTL_DEL either the fd will never be returned or the reference count has been raised already.

Userspace just needs to be changed to use EPOLL_CTL_ADD_RC and to decrement the reference count after it finished processing the event, and delete the fd data if it goes to zero either at that point or after EPOLL_CTL_DEL.


(Log in to post comments)

EPOLL_CTL_DISABLE and multithreaded applications

Posted Oct 28, 2012 14:39 UTC (Sun) by kjp (subscriber, #39639) [Link]

so both userspace and the kernel are modifying the reference count? I'm confused.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds