Re: gtkmm Monitoring IO example



Thank for your answer, this was what I feared (I am on Linus btw).
Coming from a C background, I know there is a more efficient way of doing this.

I did figure out how to get the CPU load down without re-implementing it. The only change I made to the example is the flags the call to open from O_RDONLY to O_RDWR.
The example works as expected but now without the high CPU load.

Should I report this somewhere?

Sanne


On 2015-09-25 15:13, Kjell Ahlstedt wrote:
When I tested the input example program on my dual-core PC, I got the
same result: The CPU load on one of the cores is 100% after something
is written to the fifo. Most of the relevant code is in glib. I don't
know all details, but this is what I found:

Before anything is written to the fifo, the program waits at
   read_fd = open("testfifo", O_RDONLY);
without using much CPU time (perhaps no time at all).
Once the fifo contains data to read, open() returns, and the program
enters the main loop at
   app->run();
After that, the fifo is monitored by polling. Polling is inefficient.
Probably it's the only possible way that the OS offers. It does seem a
bit extreme to use all available CPU time for polling, but probably
it's normal behaviour.

Kjell

Den 2015-09-25 kl. 08:04, skrev Sanne Ausma:
I am trying the Gtkmm Monitoring I/O example from the gtkmm-tutorial.
(https://developer.gnome.org/gtkmm-tutorial/unstable/sec-monitoring-io.html.en) The example works but after something has been written to the fifo, top shows the CPU load going to 100%. I have tried the example with both gtkmm 3.0 and 2.4 but the result is the same.

Is this normal behaviour?

Thanks,

Sanne
_______________________________________________


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]