[gmpi] Re: Topic 5: Threading

  • From: Bill Gardner <billg@xxxxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Tue, 15 Apr 2003 12:38:52 -0400


> > So, I would suggest that DSP object should be callable from multiple
>  > threads, but not simultaneously - ie they should not use thread-local
>  > storage, but they should not  be called re-entrantly from different
threads.
>
> Yes, but if the GUI communicates directly with the DSP object, this will
> require synchronization, since the GUI and DSP object can certainly be
> running simultaneously from different threads. Do you force all GUI to DSP
> object communication to go through the host?

I think so. I can think of a couple of ways this could work. The host could
provide low-level syncronisation and/or messaging primitives (queues, locks,
etc), alternately there could be a standard high-level GUI<->DSP object
communication interface (message passing?) that the host provides an
implementation of.

We'll have to decide if the spec mandates that the GUI and DSP communicate through the host. I agree it is potentially the cleanest implementation, however, it is also quite likely that such mandates will be circumvented by developers. After all, it will be easy enough to communicate a pointer via the interface and then use it directly, being careful to handle thread synchronization. I sheepishly admit doing this in DirectX . The proper way to do it is using COM interfaces and data marshalling, in case the GUI and DSP are in separate processes. My point is that the spec can mandate one design, but the actual specification is the legacy left behind once developers implement a lot of plugs. If everyone takes the same shortcuts, it tends to alter the specification in practice. My guess is most existing Dx plugs will not work if the GUI and DSP are in separate processes even though in theory they should.


My vote would be to assume all components of a plug (including GUI and DSP) are in the same process, provide a nice host messaging interface, the use of which means that thread synchronization does not have to be handled by the plug, and don't mandate that all communication must pass through the host, but make it so attractive and easy to use that everyone does it this way.

Another idea is to have the host provide messaging and stream interfaces suitable of attaching out of process components, but not mandate that everyone use them, instead provide a mechanism to test for out of process components and fail gracefully if the plug assumes an in process model.

Bill


At 06:25 AM 4/15/03 +1000, you wrote:
Bill Gardner wrote:
> > So, I would suggest that DSP object should be callable from multiple
>  > threads, but not simultaneously - ie they should not use thread-local
>  > storage, but they should not  be called re-entrantly from different
threads.
>
> Yes, but if the GUI communicates directly with the DSP object, this will
> require synchronization, since the GUI and DSP object can certainly be
> running simultaneously from different threads. Do you force all GUI to DSP
> object communication to go through the host?

I think so. I can think of a couple of ways this could work. The host could
provide low-level syncronisation and/or messaging primitives (queues, locks,
etc), alternately there could be a standard high-level GUI<->DSP object
communication interface (message passing?) that the host provides an
implementation of.

There is a book: "Real-time object-oriented modelling" by Bran Selic, et al.
which describes an approach that uses objects (say our GUI and DSP objects)
connected by message ports - all interobject communication is via
asyncronous messaging through these ports - it strikes me as being a rather
powerful approach.

A related issue concerns hidden sources of locks and thread-blocking such as
memory allocation. I'm not really knowledgable about real-time memory
allocation strategies, but I generally take the approach that allocating or
freeing memory is not something that should be done in a real-time thread.
If it is done in a real-time thread it should be done asyncronously, which
is another use for a host-provided messaging service.

I'm trying to keep in mind what I said earlier about not tacetly specifying
too much about the structure of the host - designing the plug involves
co-designing the socket, but making sure the socket is just a connector, and
not half an application is a real challenge.

Ross.


---------------------------------------------------------------------- Generalized Music Plugin Interface (GMPI) public discussion list Participation in this list is contingent upon your abiding by the following rules: Please stay on topic. You are responsible for your own words. Please respect your fellow subscribers. Please do not redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

---------------------- Bill Gardner Wave Arts, Inc. 99 Mass. Ave., Arlington, MA 02474 Tel: 781-646-3794 Fax: 781-646-7190 billg@xxxxxxxxxxxx


---------------------------------------------------------------------- Generalized Music Plugin Interface (GMPI) public discussion list Participation in this list is contingent upon your abiding by the following rules: Please stay on topic. You are responsible for your own words. Please respect your fellow subscribers. Please do not redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: