Re: How to achieve bidirectional load-time linking



In article <g35dja$85n$1@xxxxxxxxxxxxxxxxx>,
ben mitch <news@xxxxxxxxxxxx> wrote:

Hi

Consider a host application that allows users to author plugins as
dynamic libraries. The host needs to call the plugin to ask it to
perform, and also provides an API which the plugin can call:

HOST ==> PLUGIN ==> API

If the functions in API are encapsulated, data-wise, no problem:

0) HOST is the executable, PLUGIN exports functions for HOST to call,
and API is a dynamic library with exported functions for PLUGIN to call.

But what if the functions in API operate on data that is shared with
HOST? In this case, some interaction must take place between HOST and
API, and it's not clear to me what is the correct module/linking
arrangement to use. Ideas so far...

1) Function Stubs: As 0, but API function exports are stubs that call
implementations in HOST. API includes one function to connect the
function pointers associated with the stubs at start-up. Inefficient,
because one API call becomes two function calls and a pointer resolution.

Not necessarily. In languages such as Java, the runtime system might
(either directly, or in due course) optimize those calls away.

Also, IIRC, on some systems, a cross-library call translates to two
branches, anyways.

[...]

The various approaches have their pros and cons - I would much
appreciate some input - how should I choose between these? Is there,
ideally, a "standard solution"?


I doubt it. Factors influencing the answer include:

- frequency of updates to HOST and API, in relation to the size (in
#floppies, #CDs, or download minutes) of HOST and API
[As an extreme example, if size of 'HOST' is 1GB, and size of 'API' is
100kB, where API gets a bug fix every day on average, having a
separate API certainly has its advantages over distributing a
1GB+100kB (HOST+API), and most likely also over distributing a patcher
that updates that monster file]
- desired ease of use (packaging HOST and API into one file/package
prevents the error where version X of HOST, through PLUGIN, talks
with an incompatible version Y of API)
- Choosing the method with the lowest memory overhead, rather than with
the lowest function call overhead, may be desirable.

I have tried to keep this question language and OS non-specific. I
realize that there may be issues with specific compilers/systems, but I
feel there should be an underlying truth, nonetheless.

Again: I doubt this. There are significant differences between linking
systems, and modern VMs can optimize away many of the inefficiencies you
think are unavoidable.

Reinder
.



Relevant Pages

  • Re: Accessing XP Machine from a WinCE device through Network
    ... I called the WNetAddConnection3() API with the parameters set as below: ... long as you can ping devices on the private network from your device. ... So is there a possibility to allow access to the host without this Login ...
    (microsoft.public.windowsce.embedded)
  • Re: Sending HTTP request
    ... Using gethostbyname() API you'll be able to get the host address. ... With socketAPI you'll create a new socket descriptor. ... have headers files for C language (both struct definition and function ...
    (comp.sys.ibm.as400.misc)
  • How to achieve bidirectional load-time linking
    ... Consider a host application that allows users to author plugins as dynamic libraries. ... The host needs to call the plugin to ask it to perform, and also provides an API which the plugin can call: ...
    (comp.lang.misc)
  • Re: How to achieve bidirectional load-time linking
    ... implementations in HOST. ... API includes one function to connect the function pointers associated with the stubs at start-up. ... Inefficient, because one API call becomes two function calls and a pointer resolution. ...
    (comp.lang.misc)
  • Develop a Java app and you could win $1000
    ... MP3tunes Music Locker and win $1000! ... Mobile phone app Application or web-browser plugin for mobile ... Use the Music API to develop your project in one ...
    (comp.lang.java.announce)