Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kqueue/kevent project



On Tue, 12 Mar 2002, Stefan Arentz wrote:
>The documentation does not say anything about multiple threads sharing a
>kqueue.

Interestingly, the man page does mention that it can be shared between
different *processes* (if you rfork() without duplicating the file
descriptor table), but doesn't go on to explain the semantics any further.

> I think it was never intended to be used like that. Don't you
>typically create multiple queues (multiple kqueues can exist in a single
>process) with different event sources and then use worker threads to
>serialize the incoming events?

For my fraction of a cent, I would expect so.

>This is typically solved at the application level. I don't think the
>kernel should do anything to prevent this problem. Maybe it's good to
>keep a use count on the kqueue and return something like EALREADY or
>EINPROGRESS when a second thread tries to call kevent() on the same queue.
>
>However, it might be a good option to be able to change the kqueue from
>another thread (adding/removing listeners). Needs more thought :-)

Is the FreeBSD version thread-safe? If so, it seems that any reasonable
set of semantics they have is, well, reasonable :-)

Jim wrote:
>> However, the ONESHOT options allows for only one thread being awakened
>> in the first scenario (many threads, one kqueue). I'm not sufficiently
>> kqueue-savvy enough to know what the behavior would be in the second
>> scenario (one kqueue per thread, each with the same source registered as
>> ONESHOT). Does only one thread get awakened, or does one thread from
>> each kqueue get awakened?

Although the documentation isn't explicit, it seems reasonable that the
event is put on each queue that has registered interest, and that
therefore all interested threads should be awakened.

Ian
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: kqueue/kevent project (From: Stefan Arentz <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.