Re: Real Time Drawing
- From: Athanasios Anastasiou <thanos atmail com>
- To: "Liam R. E. Quin" <liam holoweb net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Real Time Drawing
- Date: Tue, 15 Mar 2005 09:57:24 +0000
Hello Liam
Thank you very much for your view on this matter.
>Multi-threaded applications sometimes get into trouble if more than
one thread is trying to communicate with the X server at the same time.
Sounds reasonable but this is not the case with my application...There
is only one thread trying to draw on a widget surface...
>An alternate architecture (I don't know how easy it is for you to
contemplate the change, though, of course) is to use gtk_add_input
>(or whatever it's called) to get a callback whenever there's data
available on the serial port, and use only a single thread. But if you
do a lot of
>processing, separate threads can be a win, especially on a multi-CPU
system :-)
I will be doing a lot of processing and that is why i have a Double
Linked List as a buffer between the producer and consumer threads. It is
possible that the processing of some of the "packets of samples" might
take some more time than others so the rest dont get droped away.
I have not looked into other things that GTK offers except the GUI stuff
and a little bit of the timers. I will look into what you suggest as it
might be a good alternative if nothing else works.
>Without seeing the errors it's hard to be certain what's happening.
You might be suffering from memory corruption (e.g. try valgrind or
memprof) e.g. >by writing to an object that you didn't actually
allocate... but if it seems to be related to timing, I'd suspect that
you are calling gtk or X functions from >multiple threads, which isn't
always safe.
This would hardly be the case as the code is quite simple but i am going
to have a second look just to make sure :-) :-).
>Also, a timer set to 20 milliseconds is likely to be more than
adequate, too, and will look pretty up-to-date for most
applications.Unset it when you >don't need it, to save CPU usage.
This is even more likely to be selected as a solution for my case, at
least for visualization.
Also could it be better that i add an expose_event handler to the widget
i want to draw and just post invalidate messages towards the widget from
the thread?
As i say in my previous email question, a document describing the
architecture of GTK would really help anyone wanting to put it in full
use. By architecture i mean, where does all the "wiring"
occurs...between the App and GTK , between X and GTK, threads in GTK,
other IO operations in GTK, stuff like that...And as you explain the
architecture just append the functions that attend that particular
piece. Its just so many functions, structures and fields in the
documentation to start reading everything one by one to figure out how
GTK works and then decide what function or part of it fits best to your
needs.
For example, i guess that the drawing operations get buffered and
submitted to the X server as a batch of operations. Could it be, that
the drawing calls from the application towards GTK coincide with the
calls from GTK to the X windows and therefore the same piece of data is
trying to be accessed by two pieces of code? (In my case the X system
and the GTK application.....[not the GTK lib. My application, that, USES
GTK])
All the best.
Thanassis
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]