[Spice-devel] [PATCH spice-server 2/2] docs: Add some notes on event scheduling and threading

Christophe Fergeau cfergeau at redhat.com
Thu Mar 28 13:08:11 UTC 2019


On Thu, Mar 28, 2019 at 04:25:31AM -0400, Frediano Ziglio wrote:
> > 
> > On Mon, Mar 11, 2019 at 02:03:33PM +0000, Frediano Ziglio wrote:
> > > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > > ---
> > >  docs/spice_threading_model.txt | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > > 
> > > diff --git a/docs/spice_threading_model.txt
> > > b/docs/spice_threading_model.txt
> > > index 9351141c8..25a3a030c 100644
> > > --- a/docs/spice_threading_model.txt
> > > +++ b/docs/spice_threading_model.txt
> > > @@ -39,6 +39,14 @@ connect, disconnect and migrate. Connect and migrate are
> > > asynchronous (the job
> > >  is done while the current thread is doing something else) while disconnect
> > >  is
> > >  synchronous (the main thread will wait for termination).
> > >  
> > > +One aspect to take into consideration is the event scheduling. SPICE uses
> > > some
> > > +`SpiceCoreInterface` to handle events. As the events will be handled from
> > > a
> > > +thread based on the core interface you have to use the correct core. Each
> > > +channel has an associated core interface which can be retrieved using
> > > +`red_channel_get_core_interface`. There's also a main core interface you
> > > can get
> > > +using `reds_get_core_interface`. `reds_core_timer_*` and
> > > `reds_core_watch_*`
> > > +functions use the main core interface.
> > 
> > Do we need a few words as to when to use the main core interface?
> > Apart from this, looks good to me.
> > 
> > Christophe
> > 
> 
> It sounds a nice idea.
> 
> But honestly I cannot came with an easy rule beside "If code runs on
> main thread like Qemu character devices or everything not running in
> a channel you can use the main core interface."

Yes, something like your rule would work "Code running in the QEMU
thread should use the main core interface. Code running in the cursor or
display channel (through RedWorker) should use xxx interface.. Code
running in other channels should use yyy. Be aware that a channel's
ClientCbs run in a different thread context than the rest of the
channel" (though the last sentence may no longer be accurate with the
work you are doing in that area).

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190328/97edca7a/attachment.sig>


More information about the Spice-devel mailing list