Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
4.43/5 (3 votes)
See more: , +
Hi all,
I have a question about marshalling.
The wikipedia page about marshlling (and other pages and articles across the web) describe marshalling as being similiar to serialization, transforming an object into a format that is suited for transporting data to other processes.

That is pretty clear. Except that I have seen the term 'marshalling' when talking about events. So is it correct to talk about 'marshalling an event to other threads'?

Personally I use the term 'synchronization' when talking about switching threads. Or is marshalling events more than just synchronizing?

There's just some confusion here, so I was wondering if anyone could explain the difference between marshalling and synchronizing between threads.

As a bonus question: Where does the word marshalling come from? Why is it used to describe the process of serialization?

Thanks.
Posted

Marhalling tends to be the term used to describe the process of transforming data so that it can either be stored (i.e., marshalling data), or moved. So, when you hear about an event being marshalled, what this means (in effect) is transforming the event so that it can be moved over threads - in other words, it's talking about recreating the state of the event on another thread suitable for being invoked on that thread.

"Where does the word marshalling come from? Why is it used to describe the process of serialization?"
It comes from the English verb - whereby marshalling means to arrange in proper order[^].
 
Share this answer
 
Comments
Sander Rossel 17-Feb-14 13:10pm    
Thank you Pete. That sounds reasonable.
One more question though. When talking about threads do you mean something like the main thread and a worker thread in an (.NET) application? If so would it matter if the language was managed or unmanaged? So in C#, for example, does the OS take care of the marshaling or is it something that .NET does every time you synchronize between threads (for example by calling the Invoke method on a Control)? Why would an event not be suitable for invocation on another thread?
Pete O'Hanlon 18-Feb-14 5:49am    
Typically, yes, you would be referring to marshalling between a background thread and the UI. The language used is fairly immaterial, as long as the operation can be marshalled - think about consuming COM events in .NET.
Sander Rossel 18-Feb-14 5:57am    
Thank you!
Pete O'Hanlon 18-Feb-14 6:13am    
You're welcome.
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file, a memory buffer, or transmitted across a network connection to be used later in the same or another computer environment. And this sequence of bits can be of any format the user chooses; however, they are usually formed as XML or binary.
The reverse of this process, converting these bits back to the original data structures and objects, is called Deserialization

Serialization example in .net: DataSet.WriteXml("myfile.xml");
Deserialization example in .net: DataSet.ReadXml("myfile.xml");

Whereas Marshaling is the process of converting managed data types to unmanaged data types. There’re many differences between the managed and unmanaged environments. One of them is not being available a data Type of one environment in the other one. In order to be able to interact with the other environment, you will need to not to change the type format, but to change its name. This is an example:
Let say a unmanaged code has a function returning a BOOL data type, you can’t interpret the return type, that’s because your managed environment doesn’t have a BOOL; although, it has a System.Boolean.

Marshalling is so named because it was first studied in 1962 by Edward Waite Marshall, then with the General Electric Corporation

Refrences:

[^]

and for more information you could take a look at this article.


[^]


http://msdn.microsoft.com/en-us/library/zah6xy75%28v=vs.110%29.aspx[
href="http://msdn.microsoft.com/en-us/library/zah6xy75%28v=vs.110%29.aspx" target="_blank" title="New Window">^
]
 
Share this answer
 
v2
Comments
Pete O'Hanlon 17-Feb-14 11:56am    
Okay, the first part is just plagiarised text. If you're going to quote someone verbatim, please take time to link to the source. And Marshalling had absolutely nothing to do with Edward Marshall - that's another of those computer urban myths.
Sander Rossel 17-Feb-14 13:21pm    
Thanks for pointing that out.
I looked up the Edward Waite Marshall thing and I did actually found it in a printed book as well: http://magic.aladdin.cs.cmu.edu/2005/08/06/higher-order-perl/
I found some other theories as well. Yours still seems to make most sense.
mehdijafary 17-Feb-14 14:13pm    
Hello Sir,
the references are added.

I found the question very interesting and i spend time and read some articles to figure out what the answer is. it was just for helping a person and myself. if it's not helpful, please don't insult my friend.

BTW, yours are the best answer I've ever seen in my whole research.
Pete O'Hanlon 17-Feb-14 14:18pm    
How is commenting that the text is plagiarised insulting? When an answer is given that directly quotes something else, it is good manners to indicate that the answer was taken from another source (and to provide a link to it). And thank you.
Sander Rossel 18-Feb-14 12:57pm    
Hello Mehdijafari,
Taking someone's text without referencing them is considered plagiarism and in many cases and countries even illegal (imprisonment may follow! not for copying a few lines from the internet though :-) ).
Now that you've added some references and interesting links I've decided to rate your answer a 5. Those are some good reads!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900