Re: How to achieve bidirectional load-time linking
- From: Reinder Verlinde <reinder@xxxxxxxxxxxxxxxx>
- Date: Mon, 16 Jun 2008 19:03:27 +0200
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
.
- Follow-Ups:
- Re: How to achieve bidirectional load-time linking
- From: ben mitch
- Re: How to achieve bidirectional load-time linking
- References:
- How to achieve bidirectional load-time linking
- From: ben mitch
- How to achieve bidirectional load-time linking
- Prev by Date: Cartooning Your Way to English or Foreign Language Learning Success
- Next by Date: Re: How to achieve bidirectional load-time linking
- Previous by thread: How to achieve bidirectional load-time linking
- Next by thread: Re: How to achieve bidirectional load-time linking
- Index(es):
Relevant Pages
|