Marshal - What does it Mean - in Plain English?

F

Frankie

I have been learning about asynchronous method calls and I keep coming
across this term, "marshal" and I would like to know what it means -
specifically. AFAIKT, it means "send" but I suspect there is a bit more than
that.

Looking to online docs, MSDN talks about the System.Runtime.Interop.Marshal
class - but I don't think that's relevant to what I'm seeing. Maybe it is...

The following is an example of the sort of thing I've been reading... so you
can see the context in which "marshal" is being used, that I am wondering
about:

<quote>
Other objects can retrieve the Form's SynchronizationContext object through
the Current property and use it later for marshaling delegate invocations to
the Form's thread. In this way, Forms no longer have to check to see if an
event they are responding to originated on another thread. The marshaling
has already been taken care of elsewhere. In essence, the responsibility for
marshaling events has been moved from the receiver of an event to the
sender.
</quote>

Does marshal, as used in the above <quote> simply mean "we're going to send
the delegate/method invocation call from one thread to another"?? such that
the method executes on the other thread???

Thanks!
 
G

G Himangi

In .Net/COM context 'Marshal' means send / make available / convert in
suitable format if required.

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
 
P

Peter Duniho

Frankie said:
I have been learning about asynchronous method calls and I keep coming
across this term, "marshal" and I would like to know what it means -
specifically. AFAIKT, it means "send" but I suspect there is a bit more than
that.

It is more than "send". Generally, marshaling involves some conversion
of data, to allow two components that don't have a common format to
still pass data between each other.

I don't think there's actually an official definition. I first heard
the term years ago in the context of OLE and in supporting 16-bit
applications on 32-bit Windows. In the latter case, it involved a thin
layer between the old API and the new one that automatically converted
function parameters and return values.

Since then I've seen what I think is a broadening of the usage. For
example, while some packaging of parameters does go on when invoking a
delegate on a Control's thread, no real conversion of data takes place.
Yet, clearly the .NET documents include that scenario, even though I
personally wouldn't otherwise consider it "marshaling".

These days it seems that the term is used to describe any situation in
which data in the form of parameters is somehow managed in any way other
than simply calling one function from another. This would include
invocations, p/invoke, remoting, and a wide variety of other scenarios.
And now, with specific methods and even classes dedicated to
marshaling, it's not even necessary for a function call to be involved
per se.

I think the main thing to understand, at least based on your previous
comment, is that it's not simply a matter of "sending" things. There
are plenty of scenarios of sending data that don't involve marshaling,
and depending on your definition of "send" there are scenarios of
marshaling that don't involve sending anything (the data is simply
passed down a chain of callers, for example). The marshaling is more
about somehow converting or rearranging the data than it is about the
exact path the data takes.

Pete
 
F

Frankie

Thanks Peter... helpful perspective.

-Frankie


Peter Duniho said:
It is more than "send". Generally, marshaling involves some conversion of
data, to allow two components that don't have a common format to still
pass data between each other.

I don't think there's actually an official definition. I first heard the
term years ago in the context of OLE and in supporting 16-bit applications
on 32-bit Windows. In the latter case, it involved a thin layer between
the old API and the new one that automatically converted function
parameters and return values.

Since then I've seen what I think is a broadening of the usage. For
example, while some packaging of parameters does go on when invoking a
delegate on a Control's thread, no real conversion of data takes place.
Yet, clearly the .NET documents include that scenario, even though I
personally wouldn't otherwise consider it "marshaling".

These days it seems that the term is used to describe any situation in
which data in the form of parameters is somehow managed in any way other
than simply calling one function from another. This would include
invocations, p/invoke, remoting, and a wide variety of other scenarios.
And now, with specific methods and even classes dedicated to marshaling,
it's not even necessary for a function call to be involved per se.

I think the main thing to understand, at least based on your previous
comment, is that it's not simply a matter of "sending" things. There are
plenty of scenarios of sending data that don't involve marshaling, and
depending on your definition of "send" there are scenarios of marshaling
that don't involve sending anything (the data is simply passed down a
chain of callers, for example). The marshaling is more about somehow
converting or rearranging the data than it is about the exact path the
data takes.

Pete
 
J

Jon Slaughter

Visiting a dictionary gives,

"9.to arrange in proper order; set out in an orderly manner; arrange
clearly: to marshal facts; to marshal one's arguments."


Which probably is how it is used in programming.
 
J

Joel Lucsy

Jon said:
Visiting a dictionary gives,

"9.to arrange in proper order; set out in an orderly manner; arrange
clearly: to marshal facts; to marshal one's arguments."
Which probably is how it is used in programming.

Subtle, but I don't believe this to be the case. To me it means more of
a "packaging" of data. Typically for crossing process or thread
boundaries. Or for sending data to a web-server. You take your data,
marshal it into another format, and send that data to the receiver. The
receiver takes the data, unpacks it back into the same or similar
format, and uses it. That entire process of sending is called marshaling.
 
J

Jon Slaughter

Joel Lucsy said:
Subtle, but I don't believe this to be the case. To me it means more of a
"packaging" of data. Typically for crossing process or thread boundaries.
Or for sending data to a web-server. You take your data, marshal it into
another format, and send that data to the receiver. The receiver takes the
data, unpacks it back into the same or similar format, and uses it. That
entire process of sending is called marshaling.
I take packing to be arranging. When you pack something into a box you are
arranging those things in a specific way as to fit in the box. I not think
the fact that you are arranging something has an implicit connect with why
your arranging it.

So I do think the definition is a very good definition for programming
except of course that it might be used in a slightly different way. I am not
necessarily saying that the definition is exact but just that it is probably
where the programming term came from. Over time it might have evolved to a
more technical term in programming but that connection still exists.

Chances are the term wasn't made out of thin air by which every programmer
first used it... and this seems to be the only logical connection. I also
see everything you said as being implicit in the definition. You do not
arrange things for no reason. In programming it just becomes more explicit
because where ever there was a marshal there was also some "communication"
between two things.

But don't get me wrong, I'm not claiming that it is the proper definition...
just that it seems the most logical(AFAIK).
 
F

Frankie

<snip>
Okay, so I send my dog to the back yard.
I have NOT marshaled my dog to the back yard. I have sent it.

Now I put my dog in a crate and ship it to Denver.
I have marshaled my dog to Denver.

Unfortunately the altitude there gets the best of Barkley. Consequently I
have Barkley cryogenically frozen.
I have serialized my dog (to the freezer)

Science progresses to the point where the dog can be thawed and brought back
to life.
My dog has been unserialized.

I can now marshal my dog back to California.

I think I get it now. Thanks.

-F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top