Re: How does gmainloop schedule GSources by priority?
Hi, On Sat, Aug 14, 2010 at 9:57 AM, cee1 fykc...@gmail.com wrote: I've written a test program, which creating watches for two GIOChannels: one for stdin with a low priority, and the other for a named pipe with a high priority. Then ran the program with no data written to the named pipe, it can still response to input of stdin, which seems like high priority sources will not block low priority sources. Priorities only matter if the sources are both ready. If only stdin has data and the higher priority one doesn't then the lower priority would run. prepare and check both return TRUE if the source is ready (should be dispatched, i.e. its callback should be invoked). the difference is that prepare is pre-poll and check is post-poll. Havoc ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: How does gmainloop schedule GSources by priority?
Hi, Havoc 2010/8/12 Havoc Pennington h...@pobox.com Hi, Anyway you are correct, the main loop does not do any fancy scheduling where it allocates time slices. Higher priorities simply always win. Havoc I've written a test program, which creating watches for two GIOChannels: one for stdin with a low priority, and the other for a named pipe with a high priority. Then ran the program with no data written to the named pipe, it can still response to input of stdin, which seems like high priority sources will not block low priority sources. I go though the code of g_io_unix_prepare, it doen't simply return true. It seems that when creating a new type of GSource, I should take care of the *prepare* method, to prevent a very high priority source of this new type blocking other sources? -- Regards, - cee1 ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: How does gmainloop schedule GSources by priority?
Hi, On Wed, Aug 11, 2010 at 10:02 PM, cee1 fykc...@gmail.com wrote: So if I have a IOChannel watch source with a high priority, and then attach an idle source, the idle source will have no change to be scheduled? An idle source will never be scheduled while any higher-priority source is ready. (that's why it's called idle it runs when the loop is idle - not doing anything else. though really it's somewhat of a misnomer because really an idle source is a run immediately and always source that happens to default to a low priority; you can set a higher priority on it and then it won't wait for idleness.) Anyway you are correct, the main loop does not do any fancy scheduling where it allocates time slices. Higher priorities simply always win. Havoc ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
How does gmainloop schedule GSources by priority?
Hi all, I've read some code snippets of gmain.c. It seems a high priority(small value of priority field of GSource struct) source will cause low priority one no change to be processed: 1. The source_list field of GMainContext points to a series of GSources ordered by priority(High - low). 2. In the prepare stage, *g_main_context_prepare* will only process GSources with highest priority that are ready. 3. In the query stage, *g_main_context_query* will only get pollfd array ready for GSources with pollfds and higher priority than the max priority returned by *g_main_context_prepare*. So if I have a IOChannel watch source with a high priority, and then attach an idle source, the idle source will have no change to be scheduled? -- Regards, - cee1 ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list