Re: fork() and progress bar...

>Ok, I've set up an extra thread with the progressbar updating
>in the main thread and the mysql query happening in the
>other thread. It works great and mysql loads and there's no
>crashes. However, when the 'Fetching...' part happens, it says
>'Fetching...', but the progressbar just flickers very fast,
>like it's updating too quickly. I tried upping the usleep()'s,
>but that never worked. Under the fork() mechanism, the for
>loops I have there did the updating at the perfect rate. If
>someone could help me out with figuring out those speed issues,
>I'd really appreciate it. I've attached a recent copy of my
>code below.

you're updating ever 5 *MICRO* seconds! first of all, the kernel will
quantize that to a minimum of 1/HZ seconds (where HZ is almost
certainly 100 on your system). second, since the screen refresh rate
is only about 70Hz, any value faster than this is wasting CPU time.
finally, none of the screen updates will happen until you return
control to GTK, which you never do, since your loop looks like:

	while (running) {
		modify progress bar

GTK never gets to control again, and so nothing is delivered to the X
server until you're all done, at which point, you'll get a brief flash
of updating, and thats it.

i would install a GTK timeout handler with a timeout of about
100msecs. cancel the timeout handler by returning FALSE from it once
the SQL thread if finished (return TRUE to have it be called
again). Use a static variable in the handler callback to decide which
direction you're moving in.


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