Re: newby stupid syncronization question...




Mark Shinwell <mrs30@cam.ac.uk> writes:

> If you add a low-priority Gtk idle function using gtk_idle_add_priority()
> containing code like
> 
>     int signalled = 0;
> 
>     pthread_mutex_lock(&signal_mutex);
>     if (signal_value == 1) {
>         /* other thread has signalled */
> 
>         signal_value = 0;
>         signalled = 1;
>     }
>     pthread_mutex_unlock(&signal_mutex);
> 
>     if (signalled) {
>         /* do whatever is required */
> 
>     }

You'll eat CPU like crazy ;-) Low priority idle functions
just mean that they don't get run when there is anything
else to do. When there is _nothing_ else to do, they will
be run continually.

Regards,
                                        Owen



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