[Y-devel] screenUpdate() and other adventures in threading

Mark Thomas mark at www.y-windows.org
Sun Feb 29 14:55:41 GMT 2004


On Sat, 28 Feb 2004, Erik wrote:

> Quick question for whoever might know -- there is a function called
> "screenUpdate" in Y/screen/screen.c which does not seem to do anything --
> that is, it isn't called by anyone or referenced in any way.  Is this
> vestigial or a debugging tool for re-rendering the screen in the debugger, am
> I missing something, or what?

I think it's vestigial, from the days before viewports automatically
updated themselves.

> Just curious.  I'm trying to decipher the exact process by which the Y window
> system does its thing (ladder diagrams and all that) in preparation for
> threading it.
>
> Actually, an overview of the main process loop might save me some
> code-exploring time, but I think I've got the basic idea anyway.

OK.  One Y `iteration' is kicked off by one of:

  A file descriptor becoming ready for writing
  A file descriptor becoming ready for reading
  A timer expiring

It's no coincidence that these are the properties of select(2) and
family.

These could mean one of:

  An IPC channel is ready for a message to be sent
    - in which case the message is sent from the queue and control returns

  An IPC channel is ready for a message to be received
    - in which case the message is received and despatched to the
      appropriate part of the server (class, object, or special
      interface).  This part can then do whatever it likes to
      handle the message.  The final result will usually be
      a combination of:

       + one or more messages being sent.
            these are queued for sending.

       + part of the widget tree being modified,
            in which case "dirty" rectangles are passed up through the
            tree to the viewports that they are contained within, which
            add them to their dirty region lists. On the way, buffered
            widgets also take note of the parts of the dirty regions that
            fall within their buffers.

  An object timer expires
    - the object's timer handling routine is called, this can do the same
      as the previous item, and bring about the same results.

  A viewport is ready to refresh
    - in which case the viewport creates a "Renderer" object for each of
      its dirty regions, and passes that to the root widget of the
      widget hierarchy.  This renderer is propagated down the widget
      hierarchy. Doing two things:

       + buffers of buffered widgets, such as Window, whose contents may
         have changed are refreshed by calling Paint on the child widgets
         of the buffered widgets.

      then

       + the buffers are rendered onto to the viewport via the
         Renderer.

Personally, I am dubious as to whether this can be effectively threaded.
Each event can have widespread effects on the objects in the server:
you're going to have to do a lot of locking.  The simplicity and
safety of a single-threaded model is very tempting to try and keep.
You're welcome to try threading it, of course, and if there are noticable
benefits, I'll certainly look at it.

Regards,

  Mark.
-- 
|| Mark Thomas
|| efaref.net
||
|| What is a "free gift?" Aren't all gifts free?



More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved