• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
listen socket with runloops strange CPU usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

listen socket with runloops strange CPU usage


  • Subject: listen socket with runloops strange CPU usage
  • From: Nicolas Berloquin <email@hidden>
  • Date: Sun, 25 Apr 2004 00:27:35 +0200

Hello !


I just noticed something very strange with a listen socket that I create by hand (bind/listen),
then transform as a CFSocket with CFSocketCreateWithNative and accept callback events.
(All inside a cocoa 10.3.x app).


If I add this CFSocketRef as a runLoopSource in the main runloop with:
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSourceRef, kCFRunLoopDefaultMode);
CPU usage for my app is around 80-90%, and this during the whole time the app runs.

I had a separate NSThread already running and I noticed that if I add this CFSocketRef as a runLoopSource
to the second thread's runLoop, CPU usage drops down to 2-4%.

That's a real huge difference. Is this expected behaviour ?

Things you might like to know:
- Same behaviour whether the listen socket is O_NONBLOCK or not.
- I also create (a little later on) CFSocketCreateConnectedToSocketSignature() as runloopsources on (either,
but always 100%) the main thread or the second thread (same result).
- I also tried running my accepted connexions on the main or the second thread (same result).
- I have a G4 bipro.

So my testing on running "everything else" on the second thread or not makes me think that it's not
foul play or bad secondary effects inside my code, downward from the socket callback reads etc.

If this is a bug (apple bug ;-)), maybe this workaround should be advertised ?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: listen socket with runloops strange CPU usage
      • From: Quinn <email@hidden>
    • Re: listen socket with runloops strange CPU usage
      • From: Mike Miller <email@hidden>
  • Prev by Date: Re: Problem within a MoreSecurity helper tool
  • Next by Date: Re: listen socket with runloops strange CPU usage
  • Previous by thread: Re: Temporarily setting DNS servers
  • Next by thread: Re: listen socket with runloops strange CPU usage
  • Index(es):
    • Date
    • Thread