Re: poll with timeout 0 in main loop
- From: Maginot Junior <maginot junior gmail com>
- To: "Juan Pablo L." <jpablolorenzetti hotmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: poll with timeout 0 in main loop
- Date: Fri, 22 Oct 2010 00:06:08 -0200
On Thu, Oct 21, 2010 at 11:27 PM, Juan Pablo L. <
jpablolorenzetti hotmail com> wrote:
Hi, i have a problem with an application i m building with glib-2.24.2 on
linux, i create a server socket which i use to create a GIOChannel and add
it to a main loop, everything was fine until i found that the application
consumes 99.8% of the CPU while waiting for connections (doing nothing else
just sitting there waiting for connections) and it gets even worse as new
connections come in because i create a new loop in each connection (i create
a thread for each connection) to deal with the incoming packages and each
connection has N handlers to process the requests, each handler has its main
loop for asynchronous communication between them and the connection thread
that owns the handlers, so i did a strace and found out that the time out
being passed to poll is 0 so for each iteration the poll returns inmediatly
therefore i m stuck with a busy wait in all main loops, so i have read the
documentation trying to find out how to modify this bahaviour but i could
find nothing ab
out it, can you please tell me why this is happenning ?? thanks!
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Can you post an snipt of your code?
And if you started a Thread and a loop inside it, it will stay interacting
if you don't stop it, this will consume CPU for sure. I think you must work
with signals or interrupts, I'm not sure about GIOChannel, maybe a snipt
would clear a bit.
[ ]'s
--
Maginot Júnior
LPIC 1 - LPIC 2 - LPIC 3 - CCNA - CLA - Forensics Analyst
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]